Search code examples
iphonefacebookuitableviewfacebook-graph-apifacebook-friends

Load Facebook friends into UITableView


I am working on integrating Facebook into my iOS app and am wondering how to load Facebook friends into a table view so that the user can select friends to invite to the game, similar to how it is done in Words With Friends.

I know that [facebook requestWithGraphPath:@"me/friends" andDelegate:self]; requests friends from Facebook, but I cannot determine what to do from there. Somehow I want to get the friend ids so that I can send them a message. Any info or advice would be much appreciated. Thanks in advance


Solution

  •  - (void)getFriendsResponse {
        FbGraphResponse *fb_graph_response = [fbGraph doGraphGet:@"me/friends" withGetVars:nil];// me/feed 
    //parse our json
       SBJSON *parser = [[SBJSON alloc] init];
       NSDictionary *   facebook_response = [parser objectWithString:fb_graph_response.htmlResponse error:nil]; 
       //init array 
            NSMutableArray * feed = (NSMutableArray *) [facebook_response objectForKey:@"data"];
            NSMutableArray *recentFriends = [[NSMutableArray alloc] init];
    
            //adding values to array
            for (NSDictionary *d in feed) {
    
                NSLog(@"see Dicitonary :%@",d );
                facebook   = [[Facebook alloc]initWithFacebookDictionary:d ];
                [recentFriends addObject:facebook];
                NSLog(@"Postsss :->>>%@",[facebook sender]);
    
                [facebook release];
            }
    
            friends = recentFriends;
    
            [self.tableView reloadData];
         }
    

    and then Show NSArray in TableView