如何将数组发送到用户可以选择朋友并发布到他们的Facebook墙上的表格 [英] How to send an array to a table where the user can select a friend and post to their Facebook wall

查看:131
本文介绍了如何将数组发送到用户可以选择朋友并发布到他们的Facebook墙上的表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码来调用Facebook请求方法,该请求调用委托方法,该方法返回一个标有'data'的关键字的NSDictionary对象。然后我通过调用 NSArray * data = [result objectForKey:@data];

I'm using the following code to call the Facebook request method, the request calls the delegate method which returns an NSDictionary object with a key labelled 'data'. I then get the friends array by calling NSArray *data = [result objectForKey:@"data"];

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

Then the code loops through that array and extracts the names outputting them to the console.

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

The problem I'm having is how do I send this array to a table where the user can select a friend and post to their FB wall.

感谢任何帮助:)

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:部分:

I'm thinking I need something like (I'm not sure what to put in the objectAtIndex:????? part:

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

然后

 [self apiGraphFriends];


推荐答案

获取Facebook的朋友照片和名称Stroe in array

get Facebook friends photo and name . Stroe in array

    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

and display the TableView

      cell.lbl_FriendsProfileName.text = [arr_FaceBookFriendName objectAtIndex:indexPath.row];

这篇关于如何将数组发送到用户可以选择朋友并发布到他们的Facebook墙上的表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆