How to Retrieve the Results of “FBSDKGraphRequest” to Use Outside?

和自甴很熟 提交于 2019-12-08 14:21:37

You need to use [FBSDKTypeUtility arrayValue] to fetch the data.

Something like this:

NSMutableArray *_results;
FBSDKGraphRequest *request = 
  [[FBSDKGraphRequest alloc] 
     initWithGraphPath:@"me/groups?fields=id""
     parameters:nil];

[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    if (!error) {
      NSArray *items = [FBSDKTypeUtility arrayValue:result[@"data"]];
      _results = [[NSSet alloc] initWithArray:items];
    }
}];

Does this solve the issue for you?

Here is an example of how this is used on the SDK Samples: https://github.com/facebook/facebook-ios-sdk/blob/652fb84a949ef358ff05afedfb2a7c408bd5c839/FBSDKShareKit/FBSDKShareKit/Internal/FBSDKGameRequestFrictionlessRecipientCache.m#L87

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!