Reputation: 3709
I am using this function:
- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string
{
}
Inside the above function I want to check which textfield I am currently dealing with, can I put a check on on that particular textfield and secondly I want to compare say textfieldB.text when I end editing it (textfieldB) to another field say textfieldA.text, are the above two scenarios possible, I appreciate in advance for any help
Upvotes: 0
Views: 84
Reputation: 830
If these are IBOutlets and declared in your interface then you can have if statements to check which textfield you are dealing with (i.e if(textField == textFieldA){doSomething;} else if (textField ==...
Also if the textFieldA are tagged (you an tag them in interface builder) then you can have a switch statement to test each case. Switch (textField.tag){...}.
You should also make you UIViewController class a "UITextFieldDelegate" and you can call a similar - (void)textFieldDidEndEditing... And make a similar comparison there.
I hope this helps
Upvotes: 1
Reputation: 6816
Try using the UITextFieldDelegate it would be better as you would not have to check for tags.
Upvotes: 0