相关疑难解决方法(0)

NSJSONSerialization错误?

在过去的10个小时里一直试图调试崩溃,最后,我把它简化为这段代码:

NSError *error = nil;
NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"payload" ofType:@"txt"]];
id obj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];
Run Code Online (Sandbox Code Playgroud)

使用NSZombieEnabled,这会在第三行(解析发生的地方)崩溃应用程序并记录:

*** -[CFString retain]: message sent to deallocated instance 0x758afa0
Run Code Online (Sandbox Code Playgroud)

内容payload.txt是:

[
   {
      "created_at":"2013-02-15T23:46:02-05:00",
      "description":"Take out the Big Gun sounded simple enough, except the Strogg were waiting. You, and a few marines like you, are the lucky ones. You've made it down in one piece and are still able to contact the fleet. The Gravity Well, the Strogg's …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c ios nsjsonserialization

13
推荐指数
1
解决办法
1145
查看次数