我有一个通过 json 从服务器接收提要的应用程序。
我一直在为 iOS5 构建它,但最近几周用 iOS6 进行了测试。我今天用 iOS5 设备进行了测试,一切都崩溃了。
代码如下所示:
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.myserver.com/news.json"]];
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
它工作没有问题,但现在它返回一个空值。数据不为空。
最佳答案
cocoa 错误3840的含义
The data couldn’t be read because it has been corrupted. (No string key for value in object around character 2.)
你应该使用像 http://www.jsoneditoronline.org/ 这样的验证器检查你的 json或http://jsonformatter.curiousconcept.com/
关于ios - 在 iOS 5 中从 Web 服务器获取 json 时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12727549/