我在我的 iOS 应用程序上使用 Facebook 进行身份验证,并使用以下方法获取提要。当我检查它是否是有效的 JSON 对象时,它返回 true,但如果我尝试解析它,它会给我错误:
Mistake: The operation couldn’t be completed. (Cocoa error 3840.)
对此可以做些什么?这是来自服务器的内容,完全有效的 JSON - http://pastebin.com/ZwTnvi5g(通过 NSLog 得到结果)。
如何修复它以便 nsjsonserialization 正确解析它?
- (void) refreshButtonPressed
{
FBRequest *request = [[FBRequest alloc] initWithSession:FBSession.activeSession graphPath:@"me/feed"];
[request startWithCompletionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
NSError *mistake;
BOOL can = [NSJSONSerialization isValidJSONObject:result];
NSLog(@"%d", can);
NSDictionary *first = [NSJSONSerialization JSONObjectWithData:result options:NSJSONReadingAllowFragments error:&mistake];
if (mistake) {
NSLog(@"Mistake: %@", [mistake localizedDescription]);
}
}];
}