I started to use IOS and the Graph Api some weeks ago. I have problems to fill a UITableView with the albums data that I retrieve from facebook. I make my appdelegete my uitabledatasource and uitabledelegate too I make the following request after the user is logged:
NSString* fql = [NSString stringWithString:@"select object_id, cover_object_id, name, description from album where can_upload=1 and owner=me ()"];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObject:fql forKey:@"query"];
[facebook requestWithMethodName:@"fql.query" andParams:params andHttpMethod:@"GET" andDelegate:self];
[theTable reloadData];
And I implement the following to the table:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.resultData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier] autorelease];
}
NSUInteger row = [indexPath row]; cell.textLabel.text = [[self.resultData objectAtIndex:row] valueForKey:@"name"];
NSLog(@"the name %@", [[self.resultData objectAtIndex:row] valueForKey:@"name"]);
return cell;
}
And a manage the result like this:
- (void)request:(FBRequest *)request didLoad:(id)result {
if ([result isKindOfClass:[NSArray class]]) {
resultData=result;
[theTable reloadData];
}
NSLog(@"Result of API call: %@", result);
}
I get a correct result of the query but the table never reload the data so it is always empty
First of all, you need to retain
resultDatainrequest:didLoad:(use the setter method!).Secondly, you should check if the table does not try reload the data at all or if something in your table view data source methods goes wrong. If the former, it is likely that
theTableis actuallynilinrequest:didLoad:so that thereloadDatacall has no effect. Check that with the debugger.If that’s not the case, we need more information. Go through the code with the debugger and check for each of the table view data source methods if they get called and where in that flow the processing goes wrong.