[转] 【iOS基础知识】之判断NSString是否为整数、浮点数
//判断是否为整形:
- (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];
}