I have a UITextField, I\'d like to restrict the maximum allowed input value in the field to be 1000. That\'s when user is inputting number inside, once the inpu
In its most basic form you can do this:
- (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString*)string
{
NSString* newText;
newText = [textField.text stringByReplacingCharactersInRange:range withString:string];
return [newText intValue] < 1000;
}
However, you also need to check if newText is an integer, because intValue returns 0 when the text starts with other characters.