AXMetricPrefixFormatter 0.1.0

AXMetricPrefixFormatter 0.1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Hiroki Akiyama (akiroom), akiroom.



Convert NSNumber(Integer) to NSString with metric prefix.

  • 0 -> 0
  • 987 -> 987
  • 1200 -> 1.2K
  • 100834923 -> 101M
  • 10500000000 -> 10.5B
  • 1230000000000 -> 1.23T
  • -10200 -> -10.2K

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

How to use it

AXMetricPrefixFormatter *metricPrefixFormatter = [[AXMetricPrefixFormatter alloc] init];

NSLog(@"%@", [metricPrefixFormatter stringWithMetricPrefixFromNumber:@(0)]);
NSLog(@"%@", [metricPrefixFormatter stringWithMetricPrefixFromNumber:@(1200)]);
NSLog(@"%@", [metricPrefixFormatter stringWithMetricPrefixFromNumber:@(100834923)]);
NSLog(@"%@", [metricPrefixFormatter stringWithMetricPrefixFromNumber:@(10500000000)]);
NSLog(@"%@", [metricPrefixFormatter stringWithMetricPrefixFromNumber:@(1230000000000)]);
NSLog(@"%@", [metricPrefixFormatter stringWithMetricPrefixFromNumber:@(-10200)]);


/*
 Console:
 0
 1.2K
 101M
 10.5B
 1.23T
 -10.2K
 */

Author

Hiroki Akiyama, [email protected]

License

AXMetricPrefixFormatter is available under the MIT license. See the LICENSE file for more info.