I need to validate a UITextField. I want only positive integers to be entered in it. How can I achieve that?
I'd set up a NSNumberFormatter to retrieve a number from the UITextFields text property. Then get an intValue from the number and check whether it's >= 0.
Update:
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setLocale:[NSLocale currentLocale]];
NSNumber *number = [formatter numberFromString:[textField text]];
[formatter release];
This should get you going. I'm not on my development machine right now so I can't test run it, maybe you need to do one or two more lines of setup. Please refer to the reference library (I posted the link above) for the available options.