//判断是否不为空
+ (BOOL)isNotBlank:(NSString *)str
{
if (str != nil && str.length != 0) {
return YES;
}
return NO;
}
//是否包含字符串
- (BOOL)myContainsString:(NSString *)other
{
NSRange range = [self rangeOfString:other];
return (range.length != 0);
}
//判断是否为整型
- (BOOL)isPureInt
{
NSScanner *scan = [NSScanner scannerWithString:self];
int val;
return [scan scanInt:&val] && [scan isAtEnd];
}
//判断是否为浮点型
- (BOOL)isPureFloat
{
NSScanner *scan = [NSScanner scannerWithString:self];
float val;
return [scan scanFloat:&val] && [scan isAtEnd];
}
//是否为数字
- (BOOL)isPureNumber
{
return [self isPureInt] || [self isPureFloat];
}
ios 字符串判断代码
最新推荐文章于 2019-05-09 15:21:35 发布