+(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