Я хочу сделать tableView с несколькими разделами, но я не хочу использовать словарь. У меня есть два массива. Я хочу, чтобы первый массив был загружен в первом разделе, а второй во втором разделе.
У меня есть arrayOne с 3 элементами и arrayTwo с 4 элементами, поэтому, как их добавить и показать в разделах.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(section == 0)
return resultArray.count;
else
return resultArray.count;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSLog(@"Number of Sections");
if(section == 0)
return @"Section 1";
if(section == 1)
return @"Section 2";
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"Table Cell Data");
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
appDelegate = (MultipleDetailViewsWithNavigatorAppDelegate *)[[UIApplication sharedApplication] delegate];
if (indexPath.section==0) {
appDelegate = (MultipleDetailViewsWithNavigatorAppDelegate *)[[UIApplication sharedApplication] delegate];
ObjectData *theCellData = [resultArray objectAtIndex:indexPath.row];
NSString *cellValue =theCellData.category;
NSLog(@"Cell Values %@",cellValue);
cell.textLabel.text = cellValue;
return cell;
}
else {
ObjectData *theCellData = [resultArray objectAtIndex:indexPath.row];
NSString *cellValue =theCellData.category;
cell.textLabel.text = cellValue;
return cell;
}
}