I'm successful in trying to set multiple reminders for a particular event at different times. However, I'm having trouble populating my TableView with reminders or UILocalNotifications with only the notifications that pertain to a particular event when I select an event from a tableview.
I realize that I have to filter local notifications. I have scheduled my local notifications with userInfo and of course alertBody, fireDate, and etc. How can I accomplish this? Most of the examples only show the entire list instead of filter certain ones.
My code:
@property (nonatomic, strong) NSMutableArray *searchResults;
- (void)viewDidLoad
{
[super viewDidLoad];
//I want to be able to populate searchResults array on load so I can display the contents in my tableView
NSArray *temp = [[UIApplication sharedApplication] scheduledLocalNotifications];
for (int i=0; i<temp.count; i++) {
UILocalNotification *localNotif = [temp objectAtIndex:i];
self.searchResults = [NSMutableArray arrayWithObjects:localNotif.alertBody, nil];
NSLog(@"My objects: %@", self.searchResults);
}
}
I get this log:
2014-03-13 10:55:42.489 My App Name[392:60b] My objects: ( "Event name" )
2014-03-13 10:55:42.492 My App Name[392:60b] My objects: ( "Event name", )
2014-03-13 10:55:42.494 My App Name[392:60b] My objects: ( "Event name", )
So I have three notifications set at different times. The first two have the same event name and the third is different - so the local temp array has three elements. Well first I want to be able to add all three events or notifications in the searchResults array so it will print just one time, so it will look like :
2014-03-13 10:55:42.489 My App Name[392:60b] My objects: ( "Event name", "Event name", "Event name" )