我目前有两个TableViewControllers。第一个有七个对象,每个日期名称列出。
Weekdays *mandag = [[Weekdays alloc] initWithName:@"Mandag" daylist:mondayArray];
Weekdays *tirsdag = [[Weekdays alloc] initWithName:@"Tirsdag" daylist:tuesdayArray];
Weekdays *onsdag = [[Weekdays alloc] initWithName:@"Onsdag" daylist:wedensdayArray];
Weekdays *torsdag = [[Weekdays alloc] initWithName:@"Torsdag" daylist:thursdayArray];
Weekdays *fredag = [[Weekdays alloc] initWithName:@"Fredag" daylist:fridayArray];
Weekdays *lordag = [[Weekdays alloc] initWithName:@"Lørdag" daylist:saturdayArray];
Weekdays *sondag = [[Weekdays alloc] initWithName:@"Søndag" daylist:sundayArray];
daylist是一个NSMutableArray。这个想法是:当天的名字显示在表-1上。并且每天的数组(日期列表)显示在表格2上 - 每天标记一个。显示名称的第一个表工作正常:
VisueltSkemaAppDelegate *appDelegate = (VisueltSkemaAppDelegate *)[[UIApplication sharedApplication] delegate];
Weekdays *ugeDag = (Weekdays *)[appDelegate.ugeDage objectAtIndex:indexPath.row];
cell.textLabel.text = ugeDag.name;
return cell;
然而,我认为我可以做同样的事情,对于第二张桌子 - 但我现在已经用了几个小时了。这就是我得到的:
VisueltSkemaAppDelegate *appDelegate = (VisueltSkemaAppDelegate *)[[UIApplication sharedApplication] delegate];
Weekdays *ugeDag = (Weekdays *)[appDelegate.ugeDage objectAtIndex:indexPath.row];
cell.textLabel.text = [ugeDag.daylist objectAtIndex:indexPath.row];
return cell;
答案 0 :(得分:0)
在InfoTable
中定义日期列表的属性(BTW最好将此控制器命名为InfoTableController)。当您在RootViewController
中选择日期时,请将此属性设置为所选日期列表。
// Next line is from your code
InfoTable *viewController = [[InfoTable alloc] initWithNibName:@"InfoTable" bundle:[NSBundle mainBundle]];
viewController.dayList = ugeDag.daylist;
...
现在,您可以在tableView:cellForRowAtIndexPath:
InfoTable
中使用它
cell.textLabel.text = [daylist objectAtIndex:indexPath.row];