项目中用到 做下记录
#pragma mark - 判断字符串是否为整型 - (BOOL)isPureInt:(NSString *)string{ NSScanner* scan = [NSScanner scannerWithString:string]; int val; return [scan scanInt:&val] && [scan isAtEnd]; } #pragma mark - 把大长串的数字做单位处理 - (NSString *)changeAsset:(NSString *)amountStr { if (amountStr && ![amountStr isEqualToString:@""]) { NSInteger num = [amountStr integerValue]; if (num >= 1000000000000) { NSString *str = [NSString stringWithFormat:@"%ld",num/1000000000000]; return [NSString stringWithFormat:@"%@万亿",str]; } else if (num >= 100000000) { NSString *str = [NSString stringWithFormat:@"%ld",num/100000000]; return [NSString stringWithFormat:@"%@亿",str]; } else if (num >= 10000000) { NSString *str = [NSString stringWithFormat:@"%ld",num/10000000]; return [NSString stringWithFormat:@"%@千万",str]; }else if (num >= 10000) { NSString *str = [NSString stringWithFormat:@"%ld",num/10000]; return [NSString stringWithFormat:@"%@万",str]; } } return amountStr; }