- (BOOL)judgeStringIsZero{ NSString *str = [self copy]; NSArray *arr = [str componentsSeparatedByString:@"."]; if (arr.count == 2 ) {//含有小数 while ([str hasSuffix:@"0"]) { str = [str substringToIndex:[str length]-1]; } if ([str hasSuffix:@"."]) { str = [str substringToIndex:[str length]-1]; } while ([str hasSuffix:@"0"]) { str = [str substringToIndex:[str length]-1]; } }else if (arr.count == 1){//不含小数 while ([str hasSuffix:@"0"]) { str = [str substringToIndex:[str length]-1]; } } if ([str isEqualToString:@"0"] || str.length == 0) return YES; return NO; }