I have a few large double like 11223322. Is there a way when I convert the double
in a NSString
that I will have the format like this: 11.223.322 ?
Asked
Active
Viewed 71 times
2

vikingosegundo
- 52,040
- 14
- 137
- 178

davidOhara
- 1,008
- 5
- 17
- 39
-
u need to format your string : use regex or substring feature – Swati Feb 13 '14 at 09:08
1 Answers
2
Try with following code;
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);

iPatel
- 46,010
- 16
- 115
- 137
-
2@christzone: Note that grouping separator is different in different locales. For example, while it's `.` in Germany (most of Europe?), it's `,` in the US. Instead of setting the grouping separator to fixed value, try using `[numberFormatter setUsesGroupingSeparator:YES];` or get the grouping separator from the current locale. – DarkDust Feb 13 '14 at 11:47