ios – NSJSONSerialization错误?

试图调试过去10个小时的崩溃,最后我简化为这段代码
NSError *error = nil;
NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"payload" ofType:@"txt"]];
id obj = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&error];

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

*** -[CFString retain]: message sent to deallocated instance 0x758afa0

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 newest weapon in its arsenal against mankind,is operational. With the fleet around Stroggos,5% of ground forces surviving,and that number dwindling by the second,your orders have changed: free your comrades. Destroy the Gravity Well.Minimum: A 100% Windows XP/Vista-compatible computer system","developer":"id Software","external_id":"2340","id":745,"image":"http://cdn.steampowered.com/v/gfx/apps/2340/header_292x136.jpg","is_subscribed":0,"link":"http://store.steampowered.com/app/2340/","price":"4.99","seller_id":2,"thumb":"http://media.steampowered.com/steamcommunity/public/images/apps/2340/5bd6e22ffdf72fdfb5ce2092fa50150de5fbb56f.jpg","title":"quake II: Ground Zero","updated_at":"2013-02-15T23:46:02-05:00","is_subscribed":0
   },{
      "created_at":"2013-02-15T23:45:59-05:00","description":"Rage through 32 single player levels and 6 deathmatch levels of sheer terror and fully immersive sound and lighting. Arm yourself against the cannibalistic Ogre,fiendish Vore and indestructible Schambler using lethal nails,fierce Thunderbolts and abominable Rocket and Grenade Launchers.Minimum: A 100% Windows XP/Vista-compatible computer system","external_id":"2310","id":742,"image":"http://cdn.steampowered.com/v/gfx/apps/2310/header_292x136.jpg","link":"http://store.steampowered.com/app/2310/","price":"9.99","thumb":"http://media.steampowered.com/steamcommunity/public/images/apps/2310/e5bdf8dc7759c573fe525d45b69011f6a173a984.jpg","title":"quake","updated_at":"2013-02-15T23:45:59-05:00","is_subscribed":0
   }
]

这只是一个2个字典的数组.我不知道是什么导致这个崩溃/这个JSON有什么问题.

UPDATE删除“is_subscribed”:数组中的第一个对象中的0将消除崩溃.

解决方法

看起来苹果在他们的类中错误地处理了这样的情况,因为你的崩溃而不是正常的零结果和错误变量的填充.您的json数据和简约代码是Apple通常需要的适当的错误报告.通过以下链接报告错误https://developer.apple.com/bugreporter/不要忘记在zip中附加项目作为它崩溃的证明.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...