I have a button that when pressed will determine if the inputted text is equal to a string. If it is, then it will transition to the next view. If it is incorrect, it will change the label text to an error message. It’s not working. Can someone critique and let me know what I’m doing wrong? Here is my code:
– (IBAction)submitButton:(UIButton *)sender {
if ([_pinTextField.text isEqualToString:@"1234"]) {
_errorLabel.text = @"PIN Accepted";
sleep(1);
[self performSegueWithIdentifier:@"ShowDetail" sender:self];
}
else _errorLabel.text = @"Incorrect PIN";
}
The segue is happening wether the if else statement is true. How do I fix that?
If the debugger is showing that it doesn’t execute the…
…line, then it’s probably a problem with the beginning of the segue as defined in the storyboard. (It should begin with the view controller instead of the button if you want to trigger it in code.)
(If that line does get executed then there’s something wrong with the
isEqualToString:test…but that doesn’t look likely.)