How to send an array to a table where the user can select a friend and post to their Facebook wall

半城伤御伤魂 提交于 2019-12-13 05:27:12

问题


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.

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.

thanks for any help :)

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);

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

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

and then

 [self apiGraphFriends];

回答1:


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];
}];

and display the TableView

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


来源:https://stackoverflow.com/questions/11646746/how-to-send-an-array-to-a-table-where-the-user-can-select-a-friend-and-post-to-t

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