I spent half my day reading the How to Cancel Local Notification Q & A. In the end, I came up with my solution, but apparently it does not work. I have a table with all my scheduled notifications.
in file H I have
@property (strong, nonatomic) UILocalNotification *theNotification;
and then in the M file:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSArray *notificationArray = [[UIApplication sharedApplication] scheduledLocalNotifications]; theNotification = [notificationArray objectAtIndex:indexPath.row]; NSLog(@"Notification to cancel: %@", [theNotification description]); // NSLOG Perfectly describes the notification to be cancelled. But then It will give me "unrecognized selector" UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Local Reminder" message:@"Cancel local reminder ?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil]; [alertView show]; [alertView release]; [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; } -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { NSLog(@"Cancel"); }else{ NSLog(@"Ok"); [[UIApplication sharedApplication] cancelLocalNotification:theNotification]; } }
If I click "Ok", I get: 2012-02-04 03: 34: 48.806 Third test [8921: 207] - [__ NSCFType encodeWithCoder:]: unrecognized selector sent to instance 0x890ae90 Program signal "SIGABRT".
If I can fully identify the notification that needs to be canceled, why does he give it to me?
objective-c xcode4 uitableview ios5 uilocalnotification
Farini Feb 04 2018-12-12T00: 00Z
source share