I’m trying to programatically fire a segue in my code, after checking if a username and password are correct (just the username at the moment due to debugging). The segue fires fine when outside the of statement, and the debug says that the username is ‘test’, which is what the condition is looking for, however the segue does’t fire.
- (IBAction)loginButton:(id)sender {
NSString *username = usernameField.text;
NSString *password = passwordField.text;
if(username == @"test")
{
[self performSegueWithIdentifier:@"loginSegue" sender:sender];
}
else{
NSLog(@"NOT PERFORMING SEGUE! USERNAME: %@ -- PASSWORD: %@", username, password);
}
}
you want
[username isEqualToString:@"test"]otherwise you are simply checking the string pointer values.