In my application I have the array, which create in Main_View_Controller from json response in loop:
Main_View_Controller.m
NSMutableArray *Cities = [[NSMutableArray alloc] init];
while (ItemsFromParsedResponse = (NSDictionary *)[enumerator nextObject]) {
AppDelegate *dataCenter = (AppDelegate*)[[UIApplication sharedApplication] delegate];
dataCenter.CityLabel = [ItemsFromParsedResponse objectForKey:@"label"];
[Cities addObject:dataCenter.CityLabel];
dataCenter = nil;
}
AppDelegate *dataCenter = (AppDelegate*)[[UIApplication sharedApplication] delegate];
dataCenter.CityInfo = Cities;
This array must be presented in Popover, containing TableView. I’ve trying to delegate array to popover same like delegate it to AppDelegate, but it’s not work. If I read dataCenter.CityInfo in my CityList_Popover_Contoller, it has nil value.
CityList_Popover_Controller.m
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{//some standard code
AppDelegate *dataCenter = (AppDelegate*)[[UIApplication sharedApplication] delegate];
cell.textLabel.text = [dataCenter.CityInfo objectAtIndex:indexPath.row];
[tableView reloadData];
return cell;
}
How can I load CityInfo only if it is not-nil? And how can I tracking changes in this array and dynamically update table content according new data in array?
Sorry if my question too simple, but I spent a lot of time to make it work.
Thanks for any advice!
Just a simple if-check should work: