multiple/optional segues from UITableViewController tableview cell

ios, uitableview

Solution

The best way would be to not use segues directly from IB but instead use `tableview:didSelectRowAtIndexPath:` and manually call them from code whenever they select a row in the table.

You should setup the segues from the tableview itself to the destinations, and not specific elements from within the table.

Something like this:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {  
    NSString *identifierOfSegueToCall;
    if (indexPath.row < 3) {
        identifierOfSegueToCall = @"theFirstViewControllerSegueIdentifier";
    } else {
        identifierOfSegueToCall = @"theSecondViewControllerSegueIdentifier";
    }

    [self performSegueWithIdentifier:identifierOfSegueToCall sender:self];
}

Problem

I have seen this topic on here but none of the solutions clicked or worked for me. I have a UITableViewController,(call it myUITableViewController) and the requirements are such that if the user selects the one of the first three rows from myUITableViewController, they will be brought to theFirstViewController, but if they had chosen any rows above three they will be brought to theSecondViewController. I am using storyboards which do not seem to allow multiple segues off a single tableview cell. However, I can add multiple segue's directly from myUITableViewController but then I am struggling with the proper segue code and have not found a proper solution.

Original source