2012-02-20 85 views
1

在我的-request:didLoad:委托方法中,我的结果是NSLog,但我无法弄清楚内容是什么?iOS - Facebook SDK,解析结果

看起来像结果是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; 
    } 
) 

回答

2

Facebook的iOS的教程,在 “第6步:使用图形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/