大型双打,格式为带点的NSString

时间:2014-02-13 09:06:32

标签: ios objective-c cocoa-touch string-formatting

我有一些像 11223322 这样的大双。当我转换double中的NSString时,我会采用以下格式: 11.223.322 吗?

1 个答案:

答案 0 :(得分:2)

尝试使用以下代码;

NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
[numberFormatter setGroupingSeparator:@"."]; // Here you can change Separator as you want 
NSString *formattedNumberString = [numberFormatter stringFromNumber:@11223322];
NSLog(@"formattedNumberString: %@", formattedNumberString);