قالب وردپرس درنا توس
Home / IOS Development / Format – NSHipster

Format – NSHipster



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:
call description on an object, it just does not cut
under most circumstances.
Actual,
the real tool for this job is Formatter :
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 NSCell ,
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
soft-advised ,
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
Number Formatter
Measurement Formatter
Dates, times and durations
Date Formats
ISO8601
Date Format
Formats Date Components Formats
Date Interval Formats
Relative Date Time Formats Time People and Places [19659015] Formats
Name Components Formats
CNPostal Address Formats
Lists and Items
List Formatting Numbers and Quantities Formatting Numbers and Quantities
] Class Example Output Availability
Number Formatter "1,234.56" iOS 2.0
macOS 10.0+
Measurement Format "- 9.80665 m / s²" iOS 10.0 +
macOS 10.12 +
Byte Count Formatter "756 KB iOS 6.0+
MacOS 10.8+
Energy Formatter " 80 kcal " iOS 8.0+
macOS 10.10+
Mass Format [19659035]" 175 lb " iOS 8.0 +
macOS 10.10+
Length Formatter "5 ft, 11 in" iOS 8.0+
macOS 10.10+
] MKDistance Formats "500 miles" iOS 7.0+
macOS 10.9+