https://useyourloaf.com/blog/local-notifications-with-ios-10/
I found this article which works if I just want to add one category of action buttons. But how should I add more than one category?
The code they provided:
UNNotificationCategory *category = [UNNotificationCategory categoryWithIdentifier:#"UYLReminderCategory"
actions:#[snoozeAction,deleteAction] intentIdentifiers:#[]
options:UNNotificationCategoryOptionNone];
NSSet *categories = [NSSet setWithObject:category];
[center setNotificationCategories:categories];
Related
Hi I'm working with Core Data and Magical Record. After receive JSON response from server. I want to create an entity, update its property and add to and array.
My code is
NSMutableArray *items = [NSMutableArray array];
NSManagedObjectContext *localContext = [NSManagedObjectContext MR_context];
Article *article = [Article MR_createEntityInContext:localContext];
[article setOrderingValue:idx];
[article updateWithApiRepresentation:articleJSON];
[items addObject:article];
I dont know why the above is not working (does not return correct items array). It's only work if I replace this line
Article *article = [Article MR_createEntityInContext:localContext];
with this line
Article *article = [[Article alloc] initWithEntity:[Article entityInManagedObjectContext:localContext] insertIntoManagedObjectContext:nil];
The main purpose is to return correct items array. Any help is much appreciate. Thanks
I have an existing program that enables me to 'tag' an email and add it to an ARRAY , I am then trying to use that ARRAY in my existing program and add it
array2 has had a group of email addresses added to it so consists of "something#sky.com,some#sky.com"
NSArray *toRecipients = [NSArray addObjectToArray:array2];
[composer setToRecipients:toRecipients];
Please don't 'flame' my code or message as I am typing the above from memory
MFMailComposeViewController *recipntNames = [[MFMailComposeViewController alloc] init];
NSArray *toRecipientsNames = [NSArray arrayWithObjects:#"something#sky.com",#"some#sky.com",nil];
[recipntNames setToRecipients:toRecipientsNames];
or use this array2 is your NSMutableArray Name
NSArray *array = [array2 copy];
[recipntNames setToRecipients:toRecipientsNames];
need more reference use this link
I would recommend to you, that using [composer setToRecipients:array2] would be better :-)
I have some set of Groups like Color,accessorie,Place, under which they have different data like color has Red, blue, pink etc and so on for other group.
So what should i do ? should i create NSSet or NSArray to keep data, like i did below or Any other good way to do it
For example,
NSSet *color = [NSSet setWithObjects:#"Red", #"Blue", #"Pink"];
NSSet *accessorie = [NSSet setWithObjects:#"Bat", #"Ball", #"Football"];
NSSet *place = [NSSet setWithObjects:#"chicago", #"Sydney", #"Lasvaegas"]
;
Let me know if question is clear
Help Appreciated and Thanks in advance :)
This question already has answers here:
The best way to remove duplicate values from NSMutableArray in Objective-C?
(14 answers)
Closed 9 years ago.
i have a nsmutablearray as is shown below. I would like to retrieve list value without redundancy. in this example i should retrive 10 20 30
NSMutableArray *array = [[NSMutableArray alloc]initWithObjects:#"10",#"20",#"30",#"30",#"30",#"30",#"20", nil];
Transform the array into a set, and then back into an array.
NSSet *set = [NSSet setWithArray:array];
NSArray *a = [set allObjects];
You can also have this new array sorted:
NSArray *a2 = [a sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
return [obj1 compare:obj2];
}];
Since iOS 5 you can use -[NSOrderedSet orderedSetWithArray:] which preserves the order:
NSArray *a2 = [[NSOrderedSet orderedSetWithArray:array] array];
NSArray *withRedunecy = [[NSSet setWithArray: array] allObjects];
This will be the one way like you can create new NSArray which has no duplicate objects or you need to create a logic for getting unique objects like insert one by one with checking is it already present or not.
Try to use this on
NSArray *array = #[#"10",#"20",#"30",#"30",#"30",#"30",#"20"];
NSArray *newArray = [[NSSet setWithArray:array] allObjects];
NSLog(#"%#", newArray);
Output :
(
30,
20,
10
)
Only this line of code will work fine .
NSSet *mySet = [NSSet setWithArray:array];
now mySet will have unique elements.so create array with this set
NSArray *myarray = [mySet allObjects];
//set up notifications
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:#selector(dataChanged:)
name:NSManagedObjectContextDidSaveNotification
object:context];
//later
- (void)dataChanged:(NSNotification *)notification{
NSDictionary *info = notification.userInfo;
NSSet *insertedObjects = [info objectForKey:NSInsertedObjectsKey];
NSSet *deletedObjects = [info objectForKey:NSDeletedObjectsKey];
NSSet *updatedObjects = [info objectForKey:NSUpdatedObjectsKey];
Is there anyway to determine from the updatedObjects which fields were actually changed?
thanks,
Michael
The following should do the trick, but you will need to use NSManagedObjectContextWillSaveNotification and access your updated objects through the same NSManagedObjectContext used to save the objects.
for(NSManagedObject *obj in updatedObjects){
NSDictionary *changes = [obj changedValues];
// now process the changes as you need
}
See the discussion in the comments.