Andrea Sindico
Andrea Sindico

Reputation: 7440

Fetching Facebook friends with Graph API

I am trying to retrieve the list of facebook friends of a logged user in an Iphone app.

this is the code I am using

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

the result I get is a NSDictionary instance with only an object inside.

Am I doing something wrong?

Upvotes: 0

Views: 602

Answers (1)

EXC_BAD_ACCESS
EXC_BAD_ACCESS

Reputation: 2707

You parse your DIctionary Data.

Sample code here,

  if ([result isKindOfClass:[NSDictionary class]]) {

            NSArray *userInfoArray=[result objectForKey:@"data"];


            NSMutableArray *userIdArray=[[NSMutableArray alloc ]init];
            NSMutableArray *userNameArray=[[NSMutableArray alloc ]init];

            for (int indexVal=0; indexVal<[userInfoArray count]; indexVal++) {
                NSDictionary *individualUserInfo=[userInfoArray objectAtIndex:indexVal];

                [userIdArray addObject:[individualUserInfo objectForKey:@"id"]];
                [userNameArray addObject:[individualUserInfo objectForKey:@"name"]];
            }

            NSLog(@"Frnd Name Array : %@ ",userNameArray);
            NSLog(@"Id Array : %@ ",userIdArray);
}

Here result is the data you received in request:DidLoad delegate method

Upvotes: 2

Related Questions