IPhone之判断是否为数字
源自:http://blog.sina.com.cn/s/blog_4adf31ea0100nw3t.html
判断是否为整形:
- (BOOL)isPureInt:(NSString *)string{ NSScanner* scan = [NSScanner scannerWithString:string]; int val; return [scan scanInt:&val] && [scan isAtEnd]; } |
判断是否为浮点形:
- (BOOL)isPureFloat:(NSString *)string{ NSScanner* scan = [NSScanner scannerWithString:string]; float val; return [scan scanFloat:&val] && [scan isAtEnd]; } |