-1

I would like to convert a big Integer (over 1 Thousand) to a String with 'K' at the end like in Instagram: Example:

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 Answers1

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