If we have a situation where you have three ViewControllers. Yellow, green and white one.
You can get to the white one through both yellow and green one. See the picture for more clarification:
When I segue from yellow to white, I prepare for segue and set a NSUinteger jimmy_hendrix value to 0;
When I segue from green to white, I prepare for segue and set a NSUinteger jimmy_hendrix value to 1;
Inside the white VC, I made IBAction and connected a BACK button to it. In there, depending on the value I want to unwind the segue which I ended up in the white VC.
This is the code I use:
- (IBAction)goBack:(UIButton *)sender {
switch (_jimmy_hendrix) {
case 0:
[self performSegueWithIdentifier:@"fromYellowToWhite" sender:self];
break;
case 1:
[self performSegueWithIdentifier:@"fromGreenToWhite" sender:self];
break;
}
}
But, I get an exception :
'Receiver (<WhiteVC: 0x15d8c850>) has no segue with identifier 'fromSuperTraenerToSuperTraenerQuestions
To make this clear, I never ctrl + dragged from the BACK button to exit and then selected the unwind segue method, because there are two unwinds I want to perform, based on which VC and which segue I used.
What is a solution to this? How to segue back to whichever ViewvController I used to get to my destionation on the first place?
IMPORTANT: I know I can make new segues, from white to yellow and green and call them. But I don't want that..I don't want to make new segues, I want to programatically unwind the existing ones.
EDIT: I forgot to mention that indeed I made unwind methods in green and yellow VC
-(IBAction)fromYellowToWhite:(UIStoryboardSegue *)segue {
}
-(IBAction)fromGreenToWhite:(UIStoryboardSegue *)segue {
}