Class

MeasurementFormatter

A formatter that provides localized representations of units and measurements.

Declaration

class MeasurementFormatter : Formatter

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>) -> String

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

func string(from: Unit) -> String

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

Constants

struct MeasurementFormatter.UnitOptions

Measurement formatter options.

Relationships

Inherits From

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software