这是我请求 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 文本未以数组或对象开头,并允许未设置片段的选项。}