I've been struggling on getting this to work. I have a list in a table view on my first page that i have split into 2 sections. When i select one of my items I will have another table view. The problem is the first section repeats itself in the second section because it doesnt recognize different sections. It just repeats itself from the other one. I have a feeling i could do this using the if statement but i'm not sure on how to implement that. I'm not sure if this is making any sense, respond for further explanation.
Thank you for the response. I have a problem though. At all the
Code:
cell1.textLabel = @"Cells 2 of section 1";
I get an error saying object cannot be set. I have a feelings it's something stupid, but I'm pretty new to this. Also I was wondering so does this affect my lists in my sections in my viewdidload and my arrays that i need in the correct rows in my didselectrowatindexpath?
Once again thank you for the help. Right now this is just causing the app to crash. But I'm not sure if this would fix my issue though. My issue is more at the didselectrowatindexpath. I understand that new section would mean new row (i.e. section 0 and section 1 both have row 0 and so on. So I'm trying to get my information in the correct sections.
Code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
// Pass the selected object to the new view controller.
NSArray* example0 = nil;
switch (indexPath.section == 0, indexPath.row)
{
case 0:
example0 = [NSArray arrayWithObjects:@"info", @"info", nil];
break;
case 1:
example0 = [NSArray arrayWithObjects:@"info", @"info", nil];
break;
case 2:
example0 = [NSArray arrayWithObjects:@"info", @"info", nil];
break;
case 3:
example0 = [NSArray arrayWithObjects:@"info", @"info", nil];
break;
case 4:
example0 = [NSArray arrayWithObjects:@"info", @"info", nil];
break;
default:
break;
}
NSArray* example1 = nil;
switch (indexPath.section == 1, indexPath.row)
{
case 0:
example1 = [NSArray arrayWithObjects:nil];
break;
case 1:
example1 = [NSArray arrayWithObjects:nil];
break;
case 2:
example1 = [NSArray arrayWithObjects:nil];
break;
default:
break;
}
if (example0)
{
RoutTableViewController* rtvc = [RoutTableViewController routTableViewControllerWithRoutNames:example0];
[self.navigationController pushViewController:rtvc animated:YES];
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}