I would like to convert a big Integer (over 1 Thousand) to a String with 'K' at the end like in Instagram:
Asked
Active
Viewed 538 times
-1

rmaddy
- 314,917
- 42
- 532
- 579

profidash_98
- 321
- 2
- 4
- 19
-
Look into the `NSByteCountFormatter` class. Much easier than all of the links you've been given. – rmaddy Aug 13 '14 at 16:22
1 Answers
2
NSString *intWithK = myint >= 1000 ? [NSString stringWithFormat:@"%dk", myint / 1000] : [NSString stringWithFormat:@"%d", myint]
Should work :)
I your integer (I called it myint
) is greater or equal to 1000 it'll divide it by 1000 and add "k", but won't do anything if it's smaller

KIDdAe
- 2,714
- 2
- 22
- 29
-
-
1That will handle things for a very specific need, but a better, more thorough answer can be found here: http://stackoverflow.com/a/23290016/3708242 – wottle Aug 13 '14 at 13:38