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 interpret and create strings that represent other data types, and to validate the text in text fields and other cells. You can also 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.
“Date Formatters” describes how to use date formatters on Mac OS X version 10.4 and later.
“Number Formatters” 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.
“Date and Number Formatters on Mac OS X v10.0 to 10.3” describes how to create and use date and number formatters using Mac OS X versions 10.0 to 10.3.
“Creating a Custom Formatter” outlines how to create custom formatter classes.
© 2008 Apple Inc. All Rights Reserved. (Last updated: 2008-10-15)