// 判断字符串是否为浮点型
- (BOOL)isPureFloat:(NSString*)string {
NSScanner *scan = [NSScannerscannerWithString:string];
float val;
return [scanscanFloat:&val] && [scan isAtEnd];
}
// 判断是否为整型
- (BOOL)isPureInt:(NSString*)string {
NSScanner *scan = [NSScannerscannerWithString:string];
int val;
return [scanscanInt:&val] && [scan isAtEnd];
}
// 判断是否以字母开头
- (BOOL)isEnglishFirst:(NSString *)str {
NSString *regular = @"^[A-Za-z].+$";
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regular];
if ([predicate evaluateWithObject:str] == YES) {
return YES;
} else {
return NO;
}
}