mardi 25 juillet 2017

Swift segue running even though if statment is not true

I am trying to stop the segue running if there is no text in the text field

@IBAction func action(_ sender: Any) {

    if( email.text != ""){
    emailaddress = email.text!
      performSegue(withIdentifier: "segue", sender: self)
    }
    else
    {
        print("enter a email")
    }

}

the "enter email " prints out in the output but it still performs the segue

sorry if this is a bit vague im very new to learning swift

Aucun commentaire:

Enregistrer un commentaire