Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Textfield input limit by character set
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789+-"] invertedSet];
NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
return [string isEqualToString:filtered];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment