A formatter that converts between numeric values and their textual representations.
- iOS 2.0+
- macOS 10.0+
- tvOS 9.0+
- watchOS 2.0+
NSNumber format the textual representation of cells that contain
NSNumber objects and convert textual representations of numeric values into
NSNumber objects. The representation encompasses integers, floats, and doubles; floats and doubles can be formatted to a specified decimal position.
NSNumber objects can also impose ranges on the numeric values cells can accept.
Fraction Digits and Significant Digits
NSNumber class provides flexible options for displaying non-zero fractional parts of numbers.
If you set the
uses property to
true, you can configure
NSNumber to display significant digits using the
maximum properties. If
false, these properties are ignored.
Otherwise, you can configure the minimum and maximum number of integer and fraction digits, or the numbers before and after the decimal separator, respectively, using the
On iOS 7 and later
NSNumber is thread safe.
In macOS 10.9 and later
NSNumber is thread safe so long as you are using the modern behavior in a 64-bit app.
On earlier versions of the operating system, or when using the legacy formatter behavior or running in 32-bit in macOS,
NSNumber is not thread safe, and you therefore must not mutate a number formatter simultaneously from multiple threads.