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

标签 objective-c ios cocoa-touch facebook-graph-api

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

相关文章:

iphone - 防止旋转过程中界面发生变化

ios - 为什么NSString initWithFormat不起作用。错误“期望的表达式” [重复项]

ios - 背景图像在 UTesting 期间导致内存警告和崩溃

ios - Xcode - 如何修复 'NSUnknownKeyException' ,原因 : … this class is not key value coding-compliant for the key X"error?

dequeueReusableCellWithReuseIdentifier 上的 iOS SIGABRT

ios - 在 Storyboard中嵌套 View Controller

ios - 在 iOS 开发中,使用 Core Graphics 和/或 Quartz 2D,如何以看起来像球体的方式绘制一个充满渐变的圆?

iphone - 我应该如何将文件包含在用户可以传输到笔记本电脑/桌面上的应用程序中

ios - 用于家长控制浏览的 iPhone 应用程序

ios - 将NSDictionary压缩为NSData的有效方法