+ (BOOL)validateNum:(NSString *)num{
NSString *numRegex = @"^[0-9]+(.[0-9]{1,2})?$";
NSPredicate *numTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", numRegex];
return [numTest evaluateWithObject:num];
}
+ (BOOL)validateNum:(NSString *)num{
NSString *numRegex = @"^[0-9]+(.[0-9]{1,2})?$";
NSPredicate *numTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", numRegex];
return [numTest evaluateWithObject:num];
}
本文标题:IOS 最多获取小数点后2位的方法
本文链接:https://www.haomeiwen.com/subject/qljugxtx.html
网友评论