gpt4 book ai didi

ios - NSJSON 序列化错误?

转载 作者:技术小花猫 更新时间:2023-10-29 10:39:18 28 4
gpt4 key购买 nike

过去 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",
"developer":"id Software",
"external_id":"2310",
"id":742,
"image":"http://cdn.steampowered.com/v/gfx/apps/2310/header_292x136.jpg",
"is_subscribed":0,
"link":"http://store.steampowered.com/app/2310/",
"price":"9.99",
"seller_id":2,
"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 有什么问题。

更新 删除数组中第一个对象中的 "is_subscribed":0 可以避免崩溃。

最佳答案

看起来 Apple 在他们的类中对此类情况的错误处理做得很糟糕,因为你得到的是崩溃而不是正常的 nil 结果和错误变量填充。您的 json 数据和简约代码是 Apple 通常要求的正确错误报告。通过以下链接报告错误 - https://developer.apple.com/bugreporter/不要忘记在 zip 中附加项目作为它崩溃的证据。

关于ios - NSJSON 序列化错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14909324/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com