//判断是否为整形:
- (BOOL)isPureInt:(NSString*)string{
NSScanner* scan = [NSScannerscannerWithString:string];
int val;
return[scan scanInt:&val] && [scanisAtEnd];
}
//判断是否为浮点形:
- (BOOL)isPureFloat:(NSString*)string{
NSScanner* scan = [NSScannerscannerWithString:string];
float val;
return[scan scanFloat:&val] && [scanisAtEnd];
}
时间: 2024-11-03 03:26:07