UILocalNotification崩溃 [英] UILocalNotification crash

查看:255
本文介绍了UILocalNotification崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以帮助我吗?

我正在设置一个UILocalNotification,当我尝试设置其userInfo字典时崩溃。 fetchedObjects包含88个对象。

I'm setting up an UILocalNotification and It crashes when I try to set its userInfo dictionary. fetchedObjects contains 88 objects.

这是代码:

    NSDictionary* myUserInfo = [NSDictionary dictionaryWithObject: fetchedObjects forKey: @"textbody"];

 UILocalNotification *localNotif = [[UILocalNotification alloc] init];
 if (localNotif == nil)
        return;

 // défining the interval
 NSTimeInterval oneMinute = 60;

 localNotif.timeZone = [NSTimeZone localTimeZone];
 NSDate *fireDate = [[NSDate alloc]initWithTimeIntervalSinceNow:oneMinute];
 localNotif.fireDate = fireDate;

 localNotif.userInfo = myUserInfo; //this is the line that crashes the app
    [fetchedObjects release];

,控制台给我这个:

Property list invalid for format: 200
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'unable to serialize userInfo: (null)'

任何想法?

推荐答案

听起来像您的userInfo字典中没有实现NSCoding协议的对象。该字典中的所有内容必须能够写入磁盘,因为您的应用程序可能在通知触发时可能不会运行。如果有东西不能序列化,那就是结果。

Sounds like there are objects in your userInfo dictionary that don't implement the NSCoding protocol. Everything in that dictionary has to be able to be written to 'disk', since your app may not be running when the notification fires. If there's something in there that can't be serialized, this is the result.

这篇关于UILocalNotification崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆