+ (BOOL)isNumber:(NSString *)strValue
{
if (strValue == nil || [strValue length] <= 0)
{
return NO;
}
NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789."] invertedSet];
NSString *filtered = [[strValue componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
if (![strValue isEqualToString:filtered])
{
return NO;
}
return YES;
}
网友评论