gpt4 book ai didi

objective-c - iOS – Facebook SDK,解析结果

转载 作者:行者123 更新时间:2023-12-01 19:22:43 31 4
gpt4 key购买 nike

在我的 -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/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com