Someone can help me
What is the right shape in Swift 2? asks to remove the "Let okAction", but then I lose the reference and the alert goes without button.
let okAction = UIAlertAction (title: "OK", style: UIAlertActionStyle.Default, handler: nil)
Complete code to facilitate:
@IBAction func singUpButtonTapped(sender: AnyObject) {
let userEmail = userEmailAddressTextField.text
let userPassword = userPasswordTextField.text
let userPasswordRepeat = userPasswordRepeatTextField.text
let userFirstName = userFirstNameTextField.text
let userLastName = userLastNameTextField.text
if( userPassword != userPasswordRepeat) {
displayAlertMessage("Passwords do not match")
return
}
if(userEmail!.isEmpty || userPassword!.isEmpty || userFirstName!.isEmpty || userLastName!.isEmpty )
{
displayAlertMessage("Passwords do not match")
return
}
}
func displayAlertMessage(userMessage:String)
{
let myAlert = UIAlertController(title: "Alert", message: userMessage, preferredStyle: UIAlertControllerStyle.Alert);
let okAction = UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil)
self.presentViewController(myAlert, animated: true, completion: nil)
}