Class

MeasurementFormatter

The NSMeasurementFormatter class provides properly formatted, localized representations of units and measurements. Use this class to create localized representations of measurements when displaying quantities of units to the user.

Overview

You use the string(from:) method to create a localized representation of an NSMeasurement object, and you use the string(from:) method to create a localized representation of an Unit object. The formatter takes into account the specified locale, unitStyle, and unitOptions when producing string representations of units and measurements.

Nested Types

MeasurementFormatter.UnitOptions

Measurement formatter options.

Symbols

Specifying the Format

var unitOptions: MeasurementFormatter.UnitOptions

The options for how the unit is formatted.

var locale: Locale!

The locale of the formatter.

var numberFormatter: NumberFormatter!

The number formatter used to format the quantity of a measurement.

Converting Measurements

func string(from: Measurement<Unit>)

Creates and returns a localized string representation of the provided measurement.

func string(from: Unit)

Creates and returns a localized string representation of the provided unit of measure.

Constants

MeasurementFormatter.UnitOptions

Measurement formatter options.

Relationships

Inherits From