objective c - If statement to check username and password entered in an iOS app -
I need help with the IF-else statement, to know if the username and password match . There will be two text fields where the username and password, username and password are not valid, the user will have to submit a submit button and a label below to display an error message. After the username and password are valid, the Model View will dismiss and will take the user to the main page of the app. Below is a valid username and password:
Username: user1
Password: test123
My existing code does not work below.
if (usernameTextField.text == @ "user1" & amp; password; TextField.text == @ "test123") {statusLabel.text = @ "Success!" ;; [Remove from Self Modul Vij Controls permission: Yes]; } Else {statusLabel.text = @ "Wrong, Please try again"; } Any help would be appreciated. Thanks! :)
I do not think there is anything wrong with your code. However, try to compare string values with the isEqualToString method and not ==. If ([usernameTextField.text is EqualToString: @ "user1"] & amp;; [PasswordTextField.textEqualToString: @ "test123"]) NSLog (@ "Success"); In addition, check that the textfields are connected in the Nib.
Comments
Post a Comment