Reputation: 842
I have two UITextField
in my app, one is for price and the other is a label for a product.
I have defined both UITextField's with @property
and @synthesize
into the .m
(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
I'm using this method to limit the entry for the price field but it seems to be affecting both field. How to limit it to one field?
Upvotes: 0
Views: 157
Reputation: 1297
The method is called when any of the UITextFields have this instance set as a delegate in Interface Builder or with code. You can check which field calls it with something like:
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
if(textField == yourSynthesizedPropertyForPriceField) {
//DO SOMETHING
}
return YES;
}
Upvotes: 3