Latest 1.1.0
Homepage https://github.com/thecatalinstan/CSOddFormatters
License MIT
Platforms ios 8.0, osx 10.8, tvos 9.0, watchos 2.0, requires ARC
Authors

Version Status Platform Carthage compatible MIT License

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

Installation through CocoaPods

Install using CocoaPods by adding this line to your Podfile:

use_frameworks!

target 'MyApp' do
  pod 'CSOddFormatters', '~> 1.0’
end

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.

Latest podspec

{
    "name": "CSOddFormatters",
    "version": "1.1.0",
    "license": "MIT",
    "summary": "A collection of useful NSFormatter subclasses.",
    "homepage": "https://github.com/thecatalinstan/CSOddFormatters",
    "authors": {
        "Cu0103tu0103lin Stan": "[email protected]"
    },
    "social_media_url": "http://twitter.com/catalinstan",
    "source": {
        "git": "https://github.com/thecatalinstan/CSOddFormatters.git",
        "tag": "1.1.0"
    },
    "module_name": "CSOddFormatters",
    "source_files": "CSOddFormatters/*.{h,m}",
    "public_header_files": [
        "CSOddFormatters/CSOddFormatters.h",
        "CSOddFormatters/CSTimeIntervalFormatter.h",
        "CSOddFormatters/CSLargeNumberFormatter.h"
    ],
    "platforms": {
        "ios": "8.0",
        "osx": "10.8",
        "tvos": "9.0",
        "watchos": "2.0"
    },
    "ios": {
        "frameworks": "Foundation"
    },
    "osx": {
        "frameworks": "Foundation"
    },
    "tvos": {
        "frameworks": "Foundation"
    },
    "watchos": {
        "frameworks": "Foundation"
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This