0

localNotificationsアプリがバックグラウンドに移行する前に、スケジュールをすべて保存したいと考えています。

localNotificationからすべてを取得し、次のUIApplicationように保存しようとします:

NSArray *allNot =[[UIApplication sharedApplication] scheduledLocalNotifications];
UILocalNotification *not = [allNot objectAtIndex:0];
[[NSUserDefaults standardUserDefaults] setObject:not forKey:@"notifications"];
[[NSUserDefaults standardUserDefaults] synchronize];

今、問題が発生します。

クラス 'UIConcreteLocalNotification' の非プロパティ値を挿入しようとしています。

my からローカル通知[UIApplication sharedApplication] scheduledLocalNotifications]を取得すると、 の配列を取得しUIConcreteLocalNotificationます。問題は、UILocalNotificationは準拠していますがNSCoding、このオブジェクトUIConcreteLocalNotificationは準拠していないことです。

どうすればこれを修正できますか?

4

1 に答える 1

0

objectAtIndex:メソッドを使用して取得したオブジェクトをキャストしましたか?

UILocalNotification *not = (UILocalNotification *) [allNot objectAtIndex:0];
于 2011-06-14T10:52:51.483 に答える