Class

MeasurementFormatter

A formatter that provides localized representations of units and measurements.

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.

Topics

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

struct MeasurementFormatter.UnitOptions

Measurement formatter options.

Relationships

Inherits From