【发布时间】:2013-07-28 15:34:44
【问题描述】:
这是我请求 JSON 的代码:
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request
success: ^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON){
NSArray *jsonArray =[JSON valueForKey:@"posts"];
[self postsToAnnotations:[self jsonToPosts:jsonArray] andUserLocationLat:lat Lon:lon];
}
failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON){
NSLog(@"response %@",JSON);
NSLog(@"Failed %@",error);
[_activityView removeFromSuperview];
}];
[operation start];
}
它在 iPhone 5 的模拟器和我的设备 (iphone 4) 上运行良好我收到此错误: 错误域 = NSCocoaErrorDomain 代码 = 3840 “操作无法完成。(可可错误 3840。)”(JSON 文本没有以数组或对象开头,并且选项允许未设置片段。) UserInfo = 0x208b9a80 {NSDebugDescription = JSON 文本没有以数组或对象开头,并且没有设置允许片段的选项。}
【问题讨论】:
-
这与 Xcode 完全无关。除此之外,您是否阅读错误消息?从中很清楚问题是什么,它甚至告诉你如何解决它。
标签: ios json afnetworking