I have a problem that I am running into when working with segues, storyboards, and IBActions. I have a SignUp Form with several text fields and UIButton for signing up. Basically, when the user taps sign up, the application will validate the text fields and then basically add that user to my database backend like FireBase. Also, if the signup was successful, I segue into another View Controller that says Welcome.. otherwise a UIAlert will be displayed and the segue does not happen. The problem is that even if the user didnt enter the correct info the welcome segue still happens. Here is what I've done:
1. Control Drag UIButton to WelcomeViewController and set the segue identifier to "welcome"
2. Made an IBAction method for the UIButton. See below:
I think my problem has to do with with my storyboard connection, but I'm not sure...
@IBAction func registerPerson(_ sender: UIButton) {
// BASIC CREATE USER CALL, THERE IS MORE TO THIS, BUT THIS JUST A SUMMARY OF THAT PORTION
createUser()
// Code for server. If data was not enetered in the database, then a UIAlert is displayed
if response.result.isFailure {
let alert = UIAlertController(title: nil, message: "Unable to register", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { (_) in
alert.dismiss(animated: true)
}))
self.present(alert, animated: true)
} else {
// Perform segeue
self.user = response.value!
self.performSegue(withIdentifier: "welcome", sender: self)
}
}
}
}
Thanks,