I’m writing application in which I need to validate text entered by user to UITextField, char by char with some method.
The difficult thing is that client wants to do all the validation before user see character in the UITextField because there might be situation that his server application doesn’t support '$' sign, so in my validation method I should replace it with 'USD' string – and he doesn’t want user to see '$', just 'USD' immediately.
I know about events like UIControlEventEditingChanged etc., but still, I don’t know 2 things:
-
how to access character typed by user before it’s seen in
UITextFieldand execute validation there -
how to subtitute this character ‘on the fly’ and put it manually to UITextField (but I suppose I’ll just append this to
[[textField] text]NSString
Thank You in advance for any help 🙂
Implement the
UITextFieldDelegatemethodtextField:shouldChangeCharactersInRange:replacementString:, e.g.: