将Facebook的朋友加载到UITableView中 [英] Load Facebook friends into UITableView

查看:151
本文介绍了将Facebook的朋友加载到UITableView中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Facebook集成到我的iOS应用程序中,并且想知道如何将Facebook的朋友加载到表格视图中,以便用户可以选择朋友来邀请游戏,类似于与朋友交谈。 / p>

我知道 [facebook requestWithGraphPath:@me / friendsandDelegate:self];
请求来自Facebook的朋友,但我无法确定从那里做什么。不知何故,我想要得到朋友的ID,以便我可以给他们一个消息。
任何信息或建议将不胜感激。
提前感谢

解决方案

   - (void)getFriendsResponse {
FbGraphResponse * fb_graph_response = [fbGraph doGraphGet:@我/朋友withGetVars:nil]; //我/ feed
//解析我们的json
SBJSON * parser = [[SBJSON alloc] init];
NSDictionary * facebook_response = [parser objectWithString:fb_graph_response.htmlResponse error:nil];
// init数组
NSMutableArray * feed =(NSMutableArray *)[facebook_response objectForKey:@data];
NSMutableArray * recentFriends = [[NSMutableArray alloc] init];

//将值添加到数组
(Feed中的NSDictionary * d){

NSLog(@see Dicitonary:%@,d);
facebook = [[Facebook alloc] initWithFacebookDictionary:d];
[recentFriends addObject:facebook];
NSLog(@Postsss: - >>>%@,[facebook sender]);

[facebook release];
}

friends = recentFriends;

[self.tableView reloadData];
}

然后在TableView中显示NSArray $ /

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

解决方案

 - (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

这篇关于将Facebook的朋友加载到UITableView中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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