user1028028 user1028028 - 4 months ago 20
iOS Question

Password confirmation with 2 UITextFields

I want the user to confirm the password he typed it... so I use two text fields.. But somehow even if both have the same password it seems to think that the 2 strin differ

if (![self.typePTextField.text isEqualToString:self.retypePLabel.text]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", @"Error") message:NSLocalizedString(@"Passwords do not match \n please retype", @"Passwords do not match \n please retype") delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
self.typePTextField.text = @"";
self.retypePLabel.text = @"";

The alert appears even if I type the same string twice... and only the first text field geets reset to @"" ...
What will fix this?


I'm guessing in the isEqual: method


should be