views:

36

answers:

1

I am calling this:

facebook requestWithGraphPath:@"me/friends" andDelegate:self]

Now I am confused on what facbook returns to me in the delegate?

How should I parse this in the (void) request:(FBRequest*) request didLoad:(id) result method? Is it returned as a dictionary?

A: 

Yes, I think it is always a dictionary. Here is some sample code for handling the "me/friends" call:

for (NSDictionary *friendData in [result objectForKey:@"data"])
{
    id friendId = [friendData objectForKey:@"id"];
    // Extract other information about the friend
}
loomer
Hmmm...now I have doubt that it can be JSON too?
EquinoX
I have taken a closer look at the FBConnect code now and the (void) request:(FBRequest*) request didLoad:(id) always gives you an object, not JSON. This object can be an array or a dictionary. You colud also implement the (void)request:(FBRequest*)request didLoadRawResponse:(NSData*)data delegate method to get the data sent back from the Facebook server, which, I suppose, is the JSON data.
loomer
Are you sure that we need to do the result objectForKey:@"data" first in the iterator?
EquinoX
Well, that depends on what you want to do but result in this case is a dictionary and the objectForKey:@"data" returns an array of dictionaries where each dictionary contains information about the friend.
loomer