0

我正在使用以下代码调用 Facebook 请求方法,该请求调用委托方法,该方法返回一个带有标记为“数据”的键的 NSDictionary 对象。然后我通过调用NSArray *data = [result objectForKey:@"data"];

然后代码循环遍历该数组并提取将它们输出到控制台的名称。

我遇到的问题是如何将此数组发送到用户可以选择朋友并发布到他们的 FB 墙上的表格。

谢谢你的帮助 :)

AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];

[[delegate facebook] requestWithGraphPath:@"me/friends" andDelegate:self];


// get the array of friends                
NSArray *data = [result objectForKey:@"data"];

NSMutableArray *array = [NSMutableArray array];    
                for (int i = 0; i < data.count; i++){
                    id object = [data objectAtIndex:i];
                    [array addObject:[object objectForKey:@"name"]];
                }

// output the array of friends
NSLog(@"list of friends %@", array);

我在想我需要类似的东西(我不确定在objectAtIndex:???部分中放入什么:

[self apiDialogFeedFriend:[[data objectAtIndex:**?????**] objectForKey:@"id"]];

接着

 [self apiGraphFriends];
4

1 回答 1

0

获取 Facebook 朋友的照片和姓名。数组中的 Stroe

    FBRequest* friendsRequest = [FBRequest requestForMyFriends];
[friendsRequest startWithCompletionHandler: ^(FBRequestConnection *connection,
                                              NSDictionary* result,
                                              NSError *error) {
    friends = [result objectForKey:@"data"];
    arr_FaceBookFriendProfileImg = [[NSMutableArray alloc] init];
    arr_FaceBookFriendName = [[NSMutableArray alloc]init];


    for (NSDictionary<FBGraphUser>* friend in friends) {

        NSString *str_FacebookFriendNames;
        str_FacebookFriendNames = friend.name;
        NSString *userPhotoUrl = [NSString stringWithFormat:@"https://graph.facebook.com/%@/picture?", friend.id];
        NSURL *url_FriendProfileImage = [NSURL URLWithString:userPhotoUrl];


        [arr_FaceBookFriendName addObject:str_FacebookFriendNames];
        [arr_FaceBookFriendProfileImg addObject:url_FriendProfileImage];

    }
  //  [table_facebookFriends reloadData];
}];

并显示 TableView

      cell.lbl_FriendsProfileName.text = [arr_FaceBookFriendName objectAtIndex:indexPath.row];
于 2014-01-25T10:16:02.200 回答