首页 > 代码库 > iOS十进制分割格式转换

iOS十进制分割格式转换

//@"123456789" 转换后 @"123,456,789"

@interface NSString (num)


- (NSString *)money;

@end

@implementation NSString (num)

- (NSString *)money{
    
    NSNumberFormatter *numFormat = [[NSNumberFormatter alloc] init];
    [numFormat setNumberStyle:NSNumberFormatterDecimalStyle];
    NSNumber *num = [NSNumber numberWithDouble:[self doubleValue]];
    
    return [numFormat stringFromNumber:num];
}
@end


iOS十进制分割格式转换