how can i make this to keep checking all the time the 2 NSSecureTextFields to know if they are equal/different to display the images without the need of a button?
the .h file:
IBOutlet NSSecureTextField *textField;
IBOutlet NSSecureTextField *textField2;
IBOutlet NSImageView *imagem;
}
- (IBAction)verificarPass:(id)sender;
the .m file:
- (IBAction)verificarPass:(id)sender;
{
NSString *senha1 = [textField stringValue];
NSString *senha2 = [textField2 stringValue];
NSImage *certo;
NSImage *errado;
certo = [NSImage imageNamed:@"Status_Accepted.png"];
errado = [NSImage imageNamed:@"Error.png"];
if ([senha1 isEqualToString:senha2]) {
[imagem setImage:certo];
}else{
[imagem setImage:errado];
}
}
Add a target method to the textField controls, triggered by the UIControlEventEditingChanged
control event:
[textField addTarget:self action:@selector(verificarPass:) forControlEvents:UIControlEventEditingChanged];