У меня есть таблица с 3 разделами, все три раздела имеют разное количество строк. Значения ячеек должны заполняться из разных массивов.
Так, как я должен узнать, какой раздел это в методе cellForRowAtIndexPath: ???
Пожалуйста, помогите !!!
Code:
- (NSInteger)tableView:(UITableView *)tv numberOfRowsInSection:(NSInteger)section
{
currentSection = section;
int number = 0;
switch (section) {
case 0:
number = self.basic.count;
break;
case 1:
number = allSectors.count;
break;
case 2:
number = 1;
break;
default:
number = 0;
break;
}
return number;
}
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tv dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier]autorelease];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
CGFloat fontSize = [UIFont systemFontSize];
CGFloat smallFontSize = [UIFont smallSystemFontSize];
switch (indexPath.section) {
case 0:
cell.textLabel.text = [self.basic objectAtIndex:indexPath.row];
break;
case 1:
cell.textLabel.text = [self.allSectors objectAtIndex:indexPath.row];
break;
case 2:
cell.textLabel.text = @"None";
break;
default:
break;
}
return cell;
}