【发布时间】:2012-01-20 05:54:02
【问题描述】:
在我的应用程序中,我有一个数组,它在 Main_View_Controller 从循环中的 json 响应中创建: 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;
这个数组必须在 Popover 中呈现,包含 TableView。我试图将数组委托给popover,就像委托给AppDelegate一样,但它不起作用。如果我在 CityList_Popover_Contoller 中读取 dataCenter.CityInfo,它的值为 nil。
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;
}
如果 CityInfo 不是零,我如何才能加载它?以及如何跟踪该数组的变化并根据数组中的新数据动态更新表格内容?
对不起,如果我的问题太简单了,但我花了很多时间才使它起作用。
感谢您的建议!
【问题讨论】:
标签: objective-c ios xcode uitableview uipopovercontroller