Introduction to Data Formatting Programming Guide For Cocoa
You use formatters to interpret and create strings that represent other data types, and to validate the text in text fields and other cells. Formatters are instances of subclasses of the abstract class, NSFormatter
. The Foundation framework provides two concrete subclasses of NSFormatter
: NSNumberFormatter
and NSDateFormatter
. (Core Foundation provides two equivalent opaque types: CFNumberFormatter and CFDateFormatter. These are similar but are not toll-free bridged.) You can create a subclass of NSFormatter
for custom formatting.
You should read this document to gain a basic understanding of how to create and use date and number formatters, and how you can create a custom formatter object.
Organization of This Document
Date Formatters describes how to use date formatters.
Number Formatters describes how to use number formatters.
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 in OS X.
Creating a Custom Formatter outlines how to create custom formatter classes.
Copyright © 2014 Apple Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2014-02-11