Reputation: 640
Is there a way to have a different prepareForSegue's for different segues coming out the same view controller?
Because I have 2 segues coming out of one view, and there obviously are some workarounds, but I was wondering if it was possible to separate the prepareForSegues into 2 entirely separate methods depending on the segue called.
Upvotes: 0
Views: 1434
Reputation: 4277
No, you cannot use two different methods. You can however call two different methods in a conditional statement like bellow:
You can check which segue was invoked:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
if ([segue.identifier isEqualToString:@"addNewCheckListItem"]) {
} else if ([segue.identifier isEqualToString:@"showExistingCheckListItem"]) {
}
}
But make sure you also set them an identifier from Interface Builder
Upvotes: 3