Saving localNotifications with UILocalNotifications and NSUserDefaults
I want to save all my scheduled localNotifications before app goes to background.
I get all the localNotification from UIApplication, and I try to save like:
NSArray *allNot =[[UIApplication sharedApplication] scheduledLocalNotifications];
UILocalNotification *not = [allNot objectAtIndex:0];
[[NSUserDefaults standardUserDefaults] setObject:not forKey:@"notifications"];
[[NSUserDefaults standardUserDefaults] synchronize];
Now the problem occurs.
Attempt to insert non-property value of class 'UIConcreteLocalNotification'.
When I get the local notifications from my [UIApplication sharedApplication] scheduledLocalNotifications] I obtain an array of UIConcreteLocalNotification. The problem is that the UILocalNotification is conform t开发者_如何学Co NSCoding but this object UIConcreteLocalNotification is not.
How can I fix this?
Did you cast the object retrieved using objectAtIndex: method?
UILocalNotification *not = (UILocalNotification *) [allNot objectAtIndex:0];
加载中,请稍侯......
精彩评论