mardi 4 juin 2019

How to fix : "IF" statements and adding return not working

Cannot convert value of type '() -> ()' to expected argument type 'Bool'

Expression type '@lvalue String?' is ambiguous without more context

Expected '{' after 'if' condition

Expected ')' in expression list

Still a beginner, following a tutorial however this piece of code seems to be working fine for him and not for me. I am using Xcode 10 and I think he is using Xcode 8.

@IBAction func signupButtonTapped(_ sender: Any) {
    print("Sign up button tapped")

//Validating required texts are not empty
    if (firstNameTextField.text?.isEmpty)! ||
    (lastNameTextField.text?.isEmpty)! ||
    (emailAddressTextField.text?.isEmpty)! ||
        (passwordTextField.text?.isEmpty)! ||

{ return }

    if ((passwordTextField.text?.elementsEqual(reenterPasswordTextField.text! != true))
        {
    return
    }


}

The if statements are meant to link back to return/not tell to continue if text fields are not completed.

Aucun commentaire:

Enregistrer un commentaire