user1028028 user1028028 - 1 year ago 76
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?

Answer Source

I'm guessing in the isEqual: method


should be

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download