Reputation: 365
I am trying to populate a UITableView with a remote JSON file. I am able to grab the JSON in the repsonseObject but am having trouble with the TableView. I am storing the JSON in an array.
My request looks like this:
- (void)makeJSONRequest
{
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@"http://www.tylacock.com/cheats.json" parameters:nil
success:^(AFHTTPRequestOperation *operation, id responseObject) {
self.jsonFromAFNetworking = [responseObject objectForKey:@"ps3"];
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
And my cellForRowAtIndexPath method looks like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
NSDictionary *tempDict = [self.jsonFromAFNetworking objectAtIndex:indexPath.row];
cell.textLabel.text = [tempDict objectForKey:@"name"];
return cell;
}
I have checked to make sure the data source is connected to the ViewController. I was actually able to accomplish this with AFNetworking 1.X but since the upgrade and method changes I am at a loss.
Upvotes: 0
Views: 3043
Reputation: 9915
You're loading the data asynchrously, so you've got to call [self.tableView reloadData]
after setting jsonFromAFNetworking
.
Upvotes: 2