Contents

Formatter

An abstract class that declares an interface for objects that create, interpret, and validate the textual representation of values.

Declaration

class Formatter

Overview

The Foundation framework provides several concrete subclasses of Formatter, including ByteCountFormatter, DateFormatter, DateComponentsFormatter, DateIntervalFormatter, MeasurementFormatter, NumberFormatter, and PersonNameComponentsFormatter.

Subclassing Notes

Formatter is intended for subclassing. A custom formatter can restrict the input and enhance the display of data in novel ways. For example, you could have a custom formatter that ensures that serial numbers entered by a user conform to predefined formats. Before you decide to create a custom formatter, make sure that you cannot configure the public subclasses to satisfy your requirements.

For instructions on how to create your own custom formatter, see Creating a Custom Formatter.

Topics

Creating Formatters

Getting Textual Representations of Object Values

Getting Object Values for Textual Representations

Validating Partial Strings

Constants

Initializers