I have a form that needs to be validated before performing a segue and also sending over the data to the next view controller. For now I'm just checking to see if all text fields are filled in:
@IBAction func startBtn(_ sender: Any) {
if(idInput.text == "" || dob1Field.text == "" || dob2Field.text == "" || dob3Field.text == ""){
print("no text")
}
}
My idea is, when the start button is pressed, check if all fields are filled, if they are use prepare
to segue to the next VC and send the data.
I'm struggling to understand how to do this, I linked the start button on the storyboard to the VC and gave it an identifier mainUse
since it is going to the mainUseController
Here is the prepare function:
override func prepare(for segue: UIStoryboardSegue, sender: Any?){
if segue.identifier == "mainUse"{
let vc = segue.destination as! mainUseController
}
}
The part I'm struggling to understand is how to call the prepare function once the check is done and succeeded. Thanks.