CSOddFormatters 1.1.0

CSOddFormatters 1.1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Nov 2016

Maintained by Cătălin Stan.



A collection of useful NSFormatter subclasses. The purpose of these formatters is to provide either missing functionality or to make the existing NSFormatters reliable for use in a high-concurrency multi-threaded environments such as that of a web-server.

I’ve used these formatters when making the criollo.io website in order to format the number of requests served and the time the app has been running.

Here’s what’s in the package:

  • CSLargeNumberFormatter - formats large numbers to a more human-readable number format. Instead of 1450000 it will output 1.4 M and so on.
  • CSTimeIntervalFormatter - makes it a bit easier and more reliable to format time intervals.

Getting Started

In your Project

import CSOddFormatters

print("\(CSLargeNumberFormatter.stringFromNumber(123456789))")

CSLargeNumberFormatter

The preffered way of using it is through the class methods stringFromNumber: and numberFromString:, but it can also be used as any regular NSNumberFormatter.

import CSOddFormatters

print(CSLargeNumberFormatter.stringFromNumber(123456789))
print(CSLargeNumberFormatter.numberFromString("123.5 M"))

Check out the complete reference at http://cocoadocs.org/docsets/CSOddFormatters/1.0.0/Classes/CSLargeNumberFormatter.html

CSTimeIntervalFormatter

The preffered way of using it is through the class methods stringFromTimeInterval:, stringFromDate:toDate: and stringFromDateComponents:, but it can also be used as any regular NSDateComponentsFormatter.

print(NSTimeIntervalFormatter.stringFromTimeInterval(3600))

print(NSTimeIntervalFormatter.stringFromDate(NSDate.distantPast(), toDate:NSDate.distantFuture))

Check out the complete reference at http://cocoadocs.org/docsets/CSOddFormatters/1.0.0/Classes/CSTimeIntervalFormatter.html

What’s Next

Check out the complete documentation on CocoaDocs.