I'm having an annoying problem where my UITextField
will return the incorrect value. Typing "test" in the UITextField called "username" should create an alert view titled "Good". But it is showing my error alert view instead.
Does anyone have any idea what I've done wrong?
Thanks
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)buttonPress {
NSString *properUsername = @"test";
NSString *givenUsername = self.username.text;
if(givenUsername == properUsername){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Good"
message:nil
delegate:nil
cancelButtonTitle:@"Okay"
otherButtonTitles:nil];
[alert show];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Wrong username/password combination"
message:nil
delegate:nil
cancelButtonTitle:@"Okay"
otherButtonTitles:nil];
[alert show];
}
}