Who Should Read This Document
Organization of This Document
This document describes how to use formatter objects to create and interpret formatted strings using formatter objects. The Foundation framework provides NSDateFormatter and NSNumberFormatter classes and the Core Foundation framework provides CFDateFormatter and CFNumberFormatter opaque types, but in contrast to many other similarly-named classes and types, they are not toll-free bridged. In Cocoa, you can use the formatters to validate the text in text fields and other cells, and to extend an abstract class to create your own formatter.
You should read this document to gain an understanding of how to use formatters in Cocoa, and to understand the difference in the behavior of formatters between Mac OS X versions 10.0 to 10.3 and from 10.4 onwards.
The following articles describe the role of formatters, how they work, and how you can configure them:
“Formatters” discusses how formatters work in general.
“NSDateFormatter on Mac OS X 10.4” describes how to use date formatters on Mac OS X version 10.4 and later.
“NSNumberFormatter on Mac OS X 10.4” describes how to use number formatters on Mac OS X version 10.4 and later.
“Formatters and User Interface Elements” describes how to set a formatter for a user interface element, and the interaction between an element and its formatter.
“Creating and Using Formatters Programmatically (Mac OS X 10.0 to 10.3)” describes how to create and use date and number formatters using Mac OS X versions 10.0 to 10.3.
“Date Format String Syntax (Mac OS X Versions 10.0 to 10.3)” describes the syntax of a date format string on Mac OS X versions 10.0 to 10.3.
“Number Format String Syntax (Mac OS X Versions 10.0 to 10.3)” describes the syntax of a number format string Mac OS X versions 10.0 to 10.3.
“Creating a Custom Formatter” outlines how to create custom formatter classes.
Last updated: 2007-03-20