【问题标题】:UILocalNotification userInfo not serializing NSURLUILocalNotification userInfo 没有序列化 NSURL
【发布时间】:2011-01-13 12:41:45
【问题描述】:

我正在努力

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

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

【问题讨论】:

    标签: iphone ios4


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-12
      • 2015-03-11
      相关资源
      最近更新 更多