开发者

UILocalNotification userInfo not serializing NSURL

开发者 https://www.devze.com 2023-02-03 20:29 出处:网络
I am trying to do UILocalNotification *notification = [[UILocalNotification alloc] init]; NSURL *urlForSomeObject=[[(NSManagedObject *)someObject objectID] URIRepresentation];

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

精彩评论

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