I'm building a very simple login verification app inside of xCode 7 using Swift. I'm extremely new to Swift and building apps in general, so I'm having some difficulty with a part of my code.
I'm checking whether or not a user has left any fields empty, and if they have, they will receive an error alert message.
However, when I go to build my project, I get the error:
Value of optional type 'String?' not unwrapped;
This is my code:
let userEmail = userEmailTextField.text
let userPassword = userPasswordTextField.text
let userRepeatPassword = repeatPasswordTextField.text
if(userEmail.isEmpty || userPassword.isEmpty || userRepeatPassword.isEmpty){
displayAlertMessage("All fields are required.") // custom made function
return;
}
Any help is appreciated.
Also, If someone could explain why my code is not functioning correctly, that would be awesome! Because, I can't seem to understand other forums explanations or fixes.