在我的 -request:didLoad:
委托(delegate)方法中,我正在 NSLog
生成结果,但我无法弄清楚内容是什么?
看起来结果是一个 NSArray
但里面是什么?我如何解析数据?
日志示例如下所示:
result: (
{
"fql_result_set" = (
{
uid2 = 1234567;
},
{
uid2 = 12345678;
}
);
name = queryID;
},
{
"fql_result_set" = (
{
"birthday_date" = "05/12/1987";
name = "John Doe";
},
{
"birthday_date" = "03/01/1978";
name = "Jane Doe";
}
);
name = queryBirthday;
}
)
最佳答案
Facebook iOS 教程在“第 6 步:使用 Graph API”中说
Note that the server response will be in JSON string format. The SDK uses an open source JSON library https://github.com/stig/json-framework/ to parse the result. If a parsing error occurs, the SDK will callback request:didFailWithError: in your delegate.
A successful request will callback request:didLoad: in your delegate. The result passed to your delegate can be an NSArray, if there are multiple results, or an NSDictionary if there is only a single result.
在您的示例中,NSLog 在“()”中打印的所有内容都是 NSArray 的一部分,而“{}”中的所有内容(顺便也有键)是 NSDictionary 的一部分,因此可以通过键(名称)访问。
http://developers.facebook.com/docs/mobile/ios/build/
关于objective-c - iOS – Facebook SDK,解析结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9362546/