c & ios n00b here,
I have been working on this problem for 3 days. I am worried that there is a fundamental concept that I am missing. I have researched and and
If you're self.beers
array is properly populated then I think you are not reloading the tableview.
Add this line after self.beers=[[NSArray alloc]initWithArray:tempArray];
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData]
});
It will reload the tableview after you receive all the data.
If that doesn't work then NSLog(@"%@",self.beers);
to make sure that self. beers is populated.
I didn't realize it is giving you an error before actually populating the tableView. I think the problem is that the name
is returning a NSString
and not an NSArray
. Actually the responseObject contains array of dictionaries so that when you iterate through the array you get a dictionary for each beer. This way you can just access the beer name with objectForKey
Beer *newBeer=[[Beer alloc]initWithName:[oneDictionary objectForKey@"name"]];
to retrieve the name of the beer.
Let me know if it works out.