我正在设计一个应用程序,它使用Facebook在表视图中显示提要..所以为了获得提要的结果我称之为方法 FBSDKGraphRequest 但我不知道如何从 FBSDKGraphRequest 外部检索结果的值,因为它们位于完成块中。我想在表格视图中显示名称和消息....
代码说明如下: -
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]initWithGraphPath:Path parameters:@{ @"fields": @"feed{from,message,created_time}",} tokenString:accessToken version:FBSDK_TARGET_PLATFORM_VERSION HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if(error)
NSLog(@"No Data");
else {
FeedCount = [NSDictionary dictionaryWithDictionary:result];
NSDictionary*feed = [FeedCount objectForKey:@"feed"];
NSArray*array1 = [feed objectForKey:@"data"];
NSArray*array3 = [array1 valueForKey:@"from"];
NSLog(@"Data:%@",array3); ---------------> **Displaying Data**
}
}];
NSLog(@"FeedCount:%@",FeedCount);----------------->**Showing Null**
任何帮助都会得到赞赏
答案 0 :(得分:0)
要从fbsdk获取字典结果,请将变量声明为__block NSDictionary *json;
然后将此内部块指定为
json =[FeedCount objectForKey:@"feed"];
你有没有试过这个,
__block NSDictionary *json;
FBSDKGraphRequest *request = [[FBSDKGraphRequest alloc]initWithGraphPath:Path parameters:@{ @"fields": @"feed{from,message,created_time}",} tokenString:accessToken version:FBSDK_TARGET_PLATFORM_VERSION HTTPMethod:@"GET"];
[request startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if(error)
NSLog(@"No Data");
else {
FeedCount = [NSDictionary dictionaryWithDictionary:result];
json = [FeedCount objectForKey:@"feed"];
NSArray*array1 = [feed objectForKey:@"data"];
NSArray*array3 = [array1 valueForKey:@"from"];
NSLog(@"Data:%@",array3); ---------------> **Displaying Data**
}
}];
NSLog(@"json:%@",json);