开发者

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜