CFNumberFormatter objects format the textual representations of CFNumber objects, and convert textual representations of numbers into CFNumber objects. The representation encompasses integers, floats, and doubles; floats and doubles can be formatted to a specified decimal position. You specify how strings are formatted and parsed by setting a format string and other properties of a CFNumberFormatter object.

The format of the format string is defined by Unicode Technical Standard #35; the version of the standard used varies with release of the operating system, and is described in Introduction to Data Formatting Programming Guide For Cocoa.

Unlike some other Core Foundation opaque types with names similar to a corresponding Cocoa Foundation class (such as CFString and NSString), CFNumberFormatter objects cannot be cast (“toll-free bridged”) to NSNumberFormatter objects.


Creating a Number Formatter

func CFNumberFormatterCreate(CFAllocator!, CFLocale!, CFNumberFormatterStyle) -> CFNumberFormatter!

Creates a new CFNumberFormatter object, localized to the given locale, which will format numbers to the given style.

Configuring a Number Formatter

func CFNumberFormatterSetFormat(CFNumberFormatter!, CFString!)

Sets the format string of a number formatter.

Examining a Number Formatter

func CFNumberFormatterCopyProperty(CFNumberFormatter!, CFNumberFormatterKey!) -> CFTypeRef!

Returns a copy of a number formatter’s value for a given key.

func CFNumberFormatterGetFormat(CFNumberFormatter!) -> CFString!

Returns a format string for the given number formatter object.

func CFNumberFormatterGetLocale(CFNumberFormatter!) -> CFLocale!

Returns the locale object used to create the given number formatter object.

func CFNumberFormatterGetStyle(CFNumberFormatter!) -> CFNumberFormatterStyle

Returns the number style used to create the given number formatter object.

Getting the CFNumberFormatter Type ID

func CFNumberFormatterGetTypeID() -> CFTypeID

Returns the type identifier for the CFNumberFormatter opaque type.

Data Types

enum CFNumberFormatterStyle

Type for constants specifying a formatter style.

struct CFNumberFormatterOptionFlags

Type for constants specifying how numbers should be parsed.

enum CFNumberFormatterPadPosition

Type for constants specifying how numbers should be padded.

class CFNumberFormatter

A reference to a CFNumberFormatter object.


Number Formatter Styles

Predefined number format styles.

Number Formatter Property Keys

The keys used in key-value pairs to specify the value of number formatter properties.

Number Format Options

These constants are used to specify how numbers should be parsed.

enum CFNumberFormatterRoundingMode

These constants are used to specify how numbers should be rounded.

Padding Positions

These constants are used to specify how numbers should be padded.

See Also

Opaque Types


The CFFileDescriptor provides an opaque type to monitor file descriptors for read and write activity via CFRunLoop.


CFStringTokenizer allows you to tokenize strings into words, sentences or paragraphs in a language-neutral way. It supports languages such as Japanese and Chinese that do not delimit words by spaces, as well as de-compounding German compounds. You can obtain Latin transcription for tokens. It also provides language identification API.