A formatter that converts between numeric values and their textual representations.
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
Number 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.
Number objects can also impose ranges on the numeric values cells can accept.
Significant Digits and Fraction Digits
Number class provides flexible options for displaying non-zero fractional parts of numbers.
If you set the
uses property to
true, you can configure
Number to display significant digits using the
maximum properties. If
false, these properties are ignored. See Configuring Significant Digits.
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
maximum properties. See Configuring Integer and Fraction Digits.
On iOS 7 and later
Number is thread-safe.
In macOS 10.9 and later
Number 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,
Number is not thread-safe, and you therefore must not mutate a number formatter simultaneously from multiple threads.