I need to validate a UITextField. I want only positive integers to be entered in it. How can I achieve that?
UITextField
From the top of my head:
Convert the string into a integer using [textField.text intValue] and check it is positive. I would do it in the - (BOOL)textFieldShouldEndEditing:(UITextField *)textField method from the UITextFieldDelegate protocol.
[textField.text intValue]
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
UITextFieldDelegate
Cheers