UILocalNotification userInfo未序列化NSURL

Man*_*ann 1 iphone ios4

我想做

UILocalNotification *notification = [[UILocalNotification alloc] init];
NSURL *urlForSomeObject=[[(NSManagedObject *)someObject objectID] URIRepresentation];
notification.fireDate  = aDate;
notification.timeZone  = [NSTimeZone systemTimeZone];
notification.soundName = UILocalNotificationDefaultSoundName;
notification.applicationIconBadgeNumber = 1;
notification.userInfo=[NSDictionary  dictionaryWithObject:urlForSomeObject            forKey:@"objectUrl"];
Run Code Online (Sandbox Code Playgroud)

当通知发生时,app给出了unable to serialize userInfo: (null)' 我检查过的异常 [NSDictionary dictionaryWithObject:urlForSomeObject forKey:@"objectUrl"]返回一个有效的字典.为什么会出现这种情况.到目前为止,我知道NSURL遵守NSCoding协议并且应该被序列化.有人可以帮帮我吗?

BJ *_*mer 6

UILocalNotification上的userInfo字典必须仅包含"plist类型".NSURL不是plist类型.我建议将URL序列化为字典中的字符串,然后在收到通知时将其转换回NSURL.