+(BOOL) validateStringContainsNumbersOnly:(NSString*)strng
{
NSCharacterSet *s = [NSCharacterSet characterSetWithCharactersInString:@"1234567890"];
s = [s invertedSet];
//And you can then use a string method to find if your string contains anything in the inverted set:
NSRange r = [strng rangeOfCharacterFromSet:s];
if (r.location != NSNotFound) {
NSLog(@"the string contains illegal characters");
return NO;
}
else
return YES;
}
No comments:
Post a Comment