Conditional Segue in Swift
ios, segue, swift, uiviewcontroller
Solution
You can do the credentials check in the following method in your `ViewController`:
func shouldPerformSegueWithIdentifier(_ identifier: String!,
sender: AnyObject!) -> Bool
In alternative, you can bind the `UIButton` to an action in your view controller, perform the checks here and then trigger a segue by code.
Problem
I want to do a "connexion" button in my app. And when you tap on it, it will open a new page if you have correct login. But, I read that we can't undo a segue, I suppose I need to call it manually. Do you have an idea ? I still tried something like this : ``` override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject) { if checkLog == true { //finish } else { // undo } } @IBAction func ConexTAP(sender: UIButton) { //check login } ```