Conversion is a tireless assignment in software development.
Most programs boil down to some variations of
Transform data into something more useful.
In the case of user-facing software,
Creating data that is human readable is an important task –
and a complex one on it.
A user's preferred language, calendar and currency
can all contribute to how information should be displayed,
which may have other limitations, such as label dimensions.
All this is to say:
description on an object, it just does not cut
under most circumstances.
the real tool for this job is
an old, abstract class deep in the heart of the foundation's framework
responsible for transforming data into textual representations.
Formatter is originated back to
used to view information and accept user input in
tables, form fields and other views in AppKit.
Much of the API design of
(NS) Formatter reflects this.
formats came in two flavors: dates and numbers.
But these days,
There are formats for everything from
physical quantities and time intervals for personal names and postal addresses.
And as if it wasn't enough to stay right,
a good deal of these have been
or otherwise replaced by more compatible APIs (which also format).
To make sense of everything,
This week's article collections group each of the embedded formats
into one of four categories:
- Numbers and Quantities
- Dates, times and durations
Date Components Formats
Date Time Formats Time People and Places  Formats
- Lists and Items
Formatting Numbers and Quantities Formatting Numbers and Quantities ] Class Example Output Availability
Formatter "1,234.56" iOS 2.0
Format "- 9.80665 m / s²" iOS 10.0 +
macOS 10.12 +
Count Formatter "756 KB iOS 6.0+
Formatter " 80 kcal " iOS 8.0+
Format " 175 lb " iOS 8.0 +
Formatter "5 ft, 11 in" iOS 8.0+
Formats "500 miles" iOS 7.0+