Inherits from NSNumberFormatter
Declared in CSLargeNumberFormatter.h

Overview

A subclass of NSNumberFormatter that adds the ability to shorten large numbers to a more human-readable number format. Instead of 1450000 it will output 1.4 M and so on.

It also makes it a bit easier and more reliable to format when dealing with a high volume of concurrent requests, by using a shared instance.

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

Tasks

Getting a String from an NSNumber

  • + stringFromNumber:

    Returns a string containing the formatted value of the provided number object.

Getting an NSNumber from a Formatted Dtring

Formatting the Output String

  •   doNotUseHumanReadableUnits

    Determines wether to use the fancy units replacement or to revert to normal NSNumberFormatter behaviour. Default is NO.

    property

Properties

doNotUseHumanReadableUnits

@property (nonatomic, assign) BOOL doNotUseHumanReadableUnits
Discussion

Determines wether to use the fancy units replacement or to revert to normal NSNumberFormatter behaviour. Default is NO.

Declared In

CSLargeNumberFormatter.h

Class Methods

numberFromString:

+ (nullable NSNumber *)numberFromString:(NSString *)string
Discussion

Returns an NSNumber object created by parsing a given string.

Parameters

string

An NSString object that is parsed to generate the returned number object.

Return Value

An NSNumber object created by parsing string using the receiver’s format of nil if there are no numbers in the passed string.

Declared In

CSLargeNumberFormatter.h

stringFromNumber:

+ (nullable NSString *)stringFromNumber:(NSNumber *)number
Discussion

Returns a string containing the formatted value of the provided number object.

Parameters

number

An NSNumber object that is parsed to create the returned string object.

Return Value

A string containing the formatted value of number using the receiver’s current settings or nil if an error has occured

Declared In

CSLargeNumberFormatter.h