In one of the apps I'm building is a view controller. This view controller has segues, each of which is supposed to be triggered by the tap of a given table view cell.
As you can tell from the code I'll post below, the app is supposed to use a switch-case statement to decide which segue the view controller is to perform. The code works for the first cell in the first section, but not for the second cell in the section. The app knows that the row number of the second cell is 1, but seems to pretend that the number is 2.
Here's the code:
As you can tell from the code I'll post below, the app is supposed to use a switch-case statement to decide which segue the view controller is to perform. The code works for the first cell in the first section, but not for the second cell in the section. The app knows that the row number of the second cell is 1, but seems to pretend that the number is 2.
Here's the code:
Code:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *segueIdentifier;
NSInteger row = [indexPath row];
switch (row) {
case 0:
segueIdentifier = @"segue1";
break;
case 1:
segueIdentifier = @"segue2";
case 2:
segueIdentifier = @"segue3";
default:
break;
}
[self performSegueWithIdentifier:segueIdentifier sender:[NSNumber numberWithInteger:[indexPath section]]];
}
Last edited: