user1320885
user1320885

Reputation: 135

Facebook Help, iOS SDK

I am currently making a Facebook iOS Application and In the app I am trying to get the users Facebook wall and put it in a UITable View.

So Far I Have:

[facebook requestWithGraphPath:@"me/home" andDelegate:self];

This is called when the view is loaded.

The in Facebook Did Receive Response, I want To Populate the table view with the posts, but this is where I have trouble. I looked everywhere for an answer and I read the apple and Facebook documentation, and they didn't help me in my case. Also If Someone Posts a Video or Image, How Would I Handle That in a TableView?? Any Help would be greatly appreciated.

Thanks, Virindh Borra

Upvotes: 0

Views: 169

Answers (2)

Matt Hudson
Matt Hudson

Reputation: 7358

You need to take the response and put it into an NSArray. Then in your UITableViewDelegate methods load up the cell:

-(void)request:(FBRequest *)request didLoad:(id)result {
   // take my result and put it into an array, usually it's an NSDictionary
    NSArray *friendsFBData = [result objectForKey:@"data"];
    NSMutableArray *friendIds = [NSMutableArray arrayWithCapacity:friendsFBData.count];
    for (int x = 0; x < friendsFBData.count; x++) {
        [friendIds addObject:[((NSDictionary*)[friendsFBData objectAtIndex:x]) objectForKey:@"id"]];
    }

   // don't forget to call loadData for your tableView
   [self reloadData];
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    // Grab data from array
    NSString *myName = [myArray objectAtIndex:indexPath.row];
    [myLabel setText:myName];
}

Upvotes: 1

valheru
valheru

Reputation: 2562

If that call is an official facebook API call, I'm assuming that it is asynchronous and therefore expects the delegate passed in to handle the updates back.

Is your object that's calling this setup as some sort of FaceBookDelegate and then expects a method called facebookDidReceiveResponse or something? That's probably the next step...retrieving the data being returned via delegate method.

Upvotes: 0

Related Questions