Create an NSCharacter set to restrict the UITextField for entering user names. I want the user to also be able to enter an underscore (therefore [A-Za-z0-9_]), but alphanumericCharacterSet does not include it. Is there a way to indicate such a range in short form? I see + (id)characterSetWithRange:(NSRange)aRange
, but I donβt understand how this will work.
I have a simple subclass of the UITextField class to which I pass a character set. The restriction works fine and does not allow the user to enter anything other than alphanumeric. Just add "_" to these discounts.
NSCharacterSet *characterSet = [NSCharacterSet alphanumericCharacterSet]; [textField setAllowed:characterSet]; [textField setFrame:frame];
objective-c iphone nscharacterset
typeoneerror May 04 '10 at 17:49 2010-05-04 17:49
source share