I want to check an NSString for special characters, i.e. anything except a-z, A-Z and 0-9.
I don\'t need to check how many special characters are present, or their p
This code allows only numbers in UITextField input.
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
if ([string rangeOfCharacterFromSet:[[NSCharacterSet decimalDigitCharacterSet] invertedSet]].location != NSNotFound)
return NO;
else
return YES;
}