I have to modify the flow of ViewControllers displayed based on a storyboard in a legacy app.
Let´s say the storyboard says to display screens as follow:
screen A -> screen B -> screen C -> screen D
Now the modification is that depending on a particular condition the screen C should not be displayed. Let say, if the condition is true the screen C is displayed otherwise it is not and screen D is directly displayed.
The flow should be:
/-------false--\
/ \
/ true \
screen A -> screen B ---------> screen C ----> screen D
I create a segue between screen B and screen D. If the condition is true I do nothing (screen C and then screen D are displayed), if the condition is false I call the segue in the ViewController for screen B:
performSegue(withIdentifier: "DirectlyDisplayScreenD", sender: self)
It is almost working... the screen C is displayed a half second and then comes the screen D.
I am a beginner with iOS, is what I did at least in principle correct ?
Is there an obvious reason why is the screen C shortly displayed ? Is it because of the storyboard ? or calling a segue is not enough ? or does it means that the ViewController for screen C is instantiated somewhere in the code ?
Is there a method to remove a ViewController of a storyboard ? I found the method instantiateViewController but I did not find a method "removeViewController"
I solved the problem by myself. I removed the legacy segue and re-built it again taking care of giving him a name. After that the application follows the flows I wish.
Thanks for all the suggestions!!