使用 UILocalNotifications 和 NSUserDefaults 保存 localNotifications
我想在应用程序进入后台之前保存所有计划的 localNotifications
。
我从 UIApplication
获取所有 localNotification
,然后尝试保存如下:
NSArray *allNot =[[UIApplication sharedApplication] scheduledLocalNotifications];
UILocalNotification *not = [allNot objectAtIndex:0];
[[NSUserDefaults standardUserDefaults] setObject:not forKey:@"notifications"];
[[NSUserDefaults standardUserDefaults] synchronize];
现在问题出现了。
尝试插入“UIConcreteLocalNotification”类的非属性值。
当我从 [UIApplicationsharedApplication]scheduledLocalNotifications]
获取本地通知时,我获得一个 UIConcreteLocalNotification
数组。问题是 UILocalNotification
符合 NSCoding
但这个对象 UIConcreteLocalNotification
不符合。
我该如何解决这个问题?
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 to NSCoding
but this object UIConcreteLocalNotification
is not.
How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否使用 objectAtIndex: 方法强制转换检索到的对象?
Did you cast the object retrieved using objectAtIndex: method?