【发布时间】:2013-04-30 17:23:01
【问题描述】:
我有一本字典,当我登录时它会显示...
{
Date = "2013-04-30 17:17:18 +0000";
Description = Kb;
EventID = "92193e58-c04a-4233-9a6c-1332bc056b20";
Title = Keyboard;
}
我正在尝试将其转换为 NSData 用于像这样的 JSON Web 服务...
- (NSData *)JSONRepresentation
{
NSDictionary *dictionary = [self dictionaryObject];
NSError *jsonError;
NSData *JSONData = [NSJSONSerialization dataWithJSONObject:dictionary
options:0
error:&jsonError]; //This is where the error occurs.
return JSONData;
}
但每次我运行它时,应用程序都会崩溃。
字典格式正确,应用程序在此行崩溃。
在 AppCode 中我得到崩溃报告...
EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xdefe))
在 Xcode 中,应用程序会停止,如果我尝试继续,它会因错误而停止...
EXC_BAD_ACCESS (code=1, address=0x0)
【问题讨论】:
-
调试器在哪里显示它爆炸了?
-
您能否提供更多上下文,例如周围的线条?
jsonError声明在哪里? -
在线
NSData *JSONData = [NSJSON....。它停在那条线上。在崩溃后的调试器中,我打印出字典,所以字典肯定是正确的。 -
添加了整个功能。
-
NSDate 会破坏它。其他值应该没问题。这是来自文档的列表:
All objects are instances of NSString, NSNumber, NSArray, NSDictionary, or NSNull.
标签: ios objective-c json nsjsonserialization