有一串比较大的数字,把这组数字格式化成以万为单位的数字
+ (NSString *)stringWithFormatNum:(NSInteger)num
{
return [NSString stringWithFormat:@"%@", num >= 10000 ? [NSString stringWithFormat:@"%0.1f万", (num / 10000.0)] : [NSString stringWithFormat:@"%zd",num]];
}
+ (NSString *)exchangeStr:(NSString *)str
{
for (NSInteger i = 0; i < str.length ; i++) {
if ([str characterAtIndex:i]<'0'||[str characterAtIndex:i]>'9') {
return str;
}
}
return [NSString stringWithFormatNum:[str integerValue]];
}