iOS 数字每隔3位添加一个逗号的

+(NSString *)countNumAndChangeformat:(NSString *)num
{
int count = ;
long long int a = num.longLongValue;
while (a != )
{
count++;
a /= ;
}
NSMutableString *string = [NSMutableString stringWithString:num];
NSMutableString *newstring = [NSMutableString string];
while (count > ) {
count -= ;
NSRange rang = NSMakeRange(string.length - , );
NSString *str = [string substringWithRange:rang];
[newstring insertString:str atIndex:];
[newstring insertString:@"," atIndex:];
[string deleteCharactersInRange:rang];
}
[newstring insertString:string atIndex:];
return newstring;
}

例:123456789

结果:123,456,789

上一篇:DevExpress使用教程:GridView经验小结(官方中文文献经典资料技巧)


下一篇:Python: PS 图像调整--饱和度调整