You can do it in the storyboard or in code:
In Storyboard
You can draw a segue from a cell to a destination view controller and give that segue a unique identifier in the property inspector. You can use this to segue to multiple destinations by having multiple cell prototypes, with each prototype having its own segue.
In Code
To do it in code, you would draw a segue from your view controller (not the cell) to each destination and give each segue a unique identifier. Then in didSelectRowAtIndexPath
, you would decide which destination you want based on the selected index path and perform the segue like
NSString *segueIdentifier = @"someIdentifier";//or whatever logic you need to determined the appropriate identifier
id sender = self;//or whatever object you want to be the sender
[self performSegueWithIdentifier:segueIdentifier sender:sender];
prepareForSegue
In prepareForSegue
, you'd have a conditional block for each possible segue identifier:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"oneSegueIdentifier"]) {
//preparation
} else if ([[segue identifier] isEqualToString:@"anotherSegueIdentifier"]) {
//other preparation
}
}