Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
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:

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:
The reason I had a problem is that I left out a break statement after the part where the value of segueIdentifier is set to "segue2."

EDIT: You beat me to it, demo!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.