2
我尝试取消本地通知。我附上一个字典有ID为以后找到它:UILocalNotification零用户信息
+ (void) send:(NSString*)title actionText:(NSString *)actionText when:(NSDate *)when count:(NSInteger)count option:(NSDictionary *)options
{
UILocalNotification *notif = [[UILocalNotification alloc] init];
//Setup code here...
notif.userInfo = options;
ALog(@"Sending notification %@ %@", notif.alertBody, notif.userInfo);
//Print: Sending notification Task Col 0 0 {id = "1-1"};
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
}
然后,当我试图找到它:
+ (void) cancelNotification:(NSString *)theId {
for(UILocalNotification *aNotif in [[UIApplication sharedApplication] scheduledLocalNotifications])
{
if([[aNotif.userInfo objectForKey:@"id"] isEqualToString:theId])
{
// Never come here: userInfo is nil!!!
}
}
}
始终将用户信息是零。我送字典:
NSMutableDictionary *info = [[NSMutableDictionary alloc] init];
[info setObject:theId forKey:@"id"];
或
[NSMutableDictionary dictionaryWithObject:theId forKey:@"id"]
具有相同的结果。 (该ID是NSString)