0
我有像這樣的數據結構在一個循環中,稱爲self.practice所產生的陣列的含量應在tableviewController目標c訪問關鍵值陣列,用於動態的tableview
// new NSDictionary
NSDictionary *highway = [[NSDictionary alloc] initWithObjectsAndKeys:@"Highway", @"description",
@"H", @"namekey",
[NSString stringWithFormat:@"%i", aHours], @"hours",
aHoursDefault.stringValue, @"hoursdefault",
[self.classlist objectAtIndex:i], @"driverclass",
nil];
NSDictionary *freeway = [[NSDictionary alloc] initWithObjectsAndKeys:@"Freeway", @"description",
@"F", @"namekey",
[NSString stringWithFormat:@"%i", fHours], @"hours",
fHoursDefault.stringValue, @"hoursdefault",
[self.classlist objectAtIndex:i], @"driverclass",
nil];
NSDictionary *stateHigway = [[NSDictionary alloc] initWithObjectsAndKeys:@"stateHighway", @"description",
@"S", @"namekey",
[NSString stringWithFormat:@"%i", sHours], @"hours",
sHoursDefault.stringValue, @"hoursdefault",
[self.classlist objectAtIndex:i], @"driverclass",
nil];
// Values of Dictionary assign to array
[self.practiceOverviewData addObject:highway];
[self.practiceOverviewData addObject:freeway];
[self.practiceOverviewData addObject:stateHighway];
// put those arrays in the "Big Array" for my tableview
[self.practice addObject:self.practiceOverviewData];
填充一個動態的tableview
現在,在我的cellForRowAtIndexPath:我無法通過
cell.textLabel.text = [[self.practice objectAtIndex:indexPath.row] objectForKey:@"description"];
感謝,迄今爲止工作,但我如何正確設置我的cellForRowAtIndexPath self.practice正確的索引:? indexPath.row不工作。 –
我編輯了答案。你可以試試那個。 – janusbalatbat
不工作 - ... self.practice objectForKey:沒有可見的接口 - 我應該再次發佈完整的代碼? –