iOS Reference Library Apple Developer
Search

Formatters

Formatters define a common interface for creating, interpreting, and validating the textual representation of objects. The Foundation framework provides two concrete subclasses of NSFormatter to generate these objects: NSNumberFormatter and NSDateFormatter. The Core Foundation provides two equivalent opaque types: CFNumberFormatter and CFDateFormatter. The formatter objects in Foundation and Core Foundation are similar but are not toll-free bridged.

In Cocoa, user interface cells that display text but have an arbitrary object as their content can use formatters for both input and output. When a cell is displayed, the cell converts an arbitrary object to a textual representation. How a cell displays the object depends on whether or not the cell has an associated formatter. If a cell has no formatter, the cell displays its content by using the localized representation of the object. If the cell has a formatter, the cell obtains a formatted string from the formatter. When the user enters text into a cell, the cell converts the text to the underlying object using its formatter.




Last updated: 2009-08-06

Did this document help you? Yes It's good, but... Not helpful...