Reputation: 15
When I click button, On satisfying some condition, I need to go from view controller 'A' to view controller 'B'. So if condition is satisfied i am writing in that if block
self.performSegue(withIdentifier: "fistBump", sender: self)
but irrespective of condition (if the condition is not met also) it is navigating to 'B' view controller.
I gave segue('fistBump') from View Controller 'A' to navigation controller scene(not to 'B' scene) in storyboard for my other purposes.
Upvotes: 0
Views: 2553
Reputation: 6151
I suspect you are attaching the segue from a UI element to ViewControllerB
, rather than directly from ViewControllerA
.
Some cases, it makes sense. When you have no condition to evaluate, you can directly fire segue from UI elements.
However, when u would like to evaluate a condition, it is a better practice, if u attach the viewControllers with the segue, and fire the segue programatically, when your condition is evaluated. You need to drag from the yellow circle the segue to the target viewController, and name your segue.
Upvotes: 1