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 534 times
-1
rmaddy
- 307,833
- 40
- 508
- 550
profidash_98
- 254
- 2
- 3
- 15
-
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,643
- 2
- 21
- 28
-
-
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