I got list of all scheduled notifications using
[[UIApplication sharedApplication] scheduledLocalNotifications].
Now i want array of all firedates to compare it with today’s date and give an alertview telling the due today reminder.
i did it by this way but am not sure whether it will work fine. please correct me as am new to iphone development.
NSArray *arrayoflocalnotifications = [[NSArray alloc] initWithArray:[[UIApplication sharedApplication]scheduledLocalNotifications]];
for (UILocalNotification *localnotif in arrayoflocalnotifications)
{
NSLog(@"array of firedate is %@", localnotif);
if ([localnotif.fireDate isEqualToDate:[NSDate date]])
{
NSLog(@"Got a duetoday reminder...");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"AlertView" message:@"Due reminder for today" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
[alert show];
[alert release];
}
}
Just use compare: function to compare two different dates. Use it like;
compare: gives you flexibility to compare if the date is before or after certain date by comparing it to NSOrderedAscending/NSOrderedDescending.