ios – How to stop Segue if condition is false swift

0
69

[ad_1]

I am try to create password and confirm password and i want to cancel the segue if password does not match. I want to cancel the segue in the else statement can someone please help me out.:

              import UIKit

          class ViewController: UIViewController {
            

              @IBOutlet weak var firstName: UITextField!
              @IBOutlet weak var lastName: UITextField!
              @IBOutlet weak var emailId: UITextField!
              @IBOutlet weak var password: UITextField!
              @IBOutlet weak var confirm: UITextField!
              @IBOutlet weak var submit: UIButton!
              
              let systemBlue = UIColor(red: 0/255, green: 122/255, blue: 255/255, alpha: 
              1.0).cgColor
              
              func registerButtonTapped() -> Bool {

                      if password.text == confirm.text {
                          
                          return true
                      } else {
                      
                          return false
                      }
                }
              
              override func viewDidLoad() {
                  super.viewDidLoad()
                  
                  firstName?.layer.borderColor = systemBlue
                  firstName?.layer.borderWidth = 1.0
                  firstName?.layer.cornerRadius = 10
                  
                  lastName?.layer.borderColor = systemBlue
                  lastName?.layer.borderWidth = 1.0
                  lastName?.layer.cornerRadius = 10
                  
                  emailId?.layer.borderColor = systemBlue
                  emailId?.layer.borderWidth = 1.0
                  emailId?.layer.cornerRadius = 10
                  
                  password?.layer.borderColor = systemBlue
                  password?.layer.borderWidth = 1.0
                  password?.layer.cornerRadius = 10
                  
                  confirm?.layer.borderColor = systemBlue
                  confirm?.layer.borderWidth = 1.0
                  confirm?.layer.cornerRadius = 10
                
                  submit?.layer.borderColor = systemBlue
                  submit?.layer.borderWidth = 2.0
                  submit?.layer.cornerRadius = 10
                  submit?.titleLabel?.textAlignment = NSTextAlignment.center
                  
                
                  
                  
                  
              }
              

              
              @IBAction func submitButton() {
                  var checked: Bool = false
                  checked = registerButtonTapped()
                  
                  if(checked == true){
                  
                  }
                  else{
                      self.performSegue(withIdentifier: "transmition", sender: nil)
                  }
                  
              }
              
              override func shouldPerformSegue(withIdentifier identifier: String, 
              sender: Any?) -> Bool {
                  return false
              }
              
          }

This is the code for Viewcontroller. I dont know what else to say stackoverflow keeps saying to add more details

[ad_2]