开发者

UILocalNotification userInfo not serializing NSURL

I am trying to do

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

when notification occurs app gives the exception unable to serialize userInfo: (null)' I have checked that [NSDictionary dictionaryWithObject:urlForSomeObject forKey:@"objectUrl"] returns a valid dictionary. why is this behavior occurring. As far i knw NSURL adhere to N开发者_JAVA技巧SCoding protocol and should be serialized. can somebody help me out?


The userInfo dictionary on a UILocalNotification must contain only "plist types". NSURL is not a plist type. I suggest serializing the URL as a string in the dictionary, then converting it back to an NSURL when you receive the notification.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜