Generic Structure


A numeric quantity labeled with a unit of measure, with support for unit conversion and unit-aware calculations.


Measurements support a large set of operators, including +, -, *, /, and a full set of comparison operators.


Creating a Measurement

init(value: Double, unit: UnitType)

Create a Measurement given a specified value and unit.

Accessing the Value and Units

let unit: UnitType

The unit component of the Measurement.

var value: Double

The value component of the Measurement.

Converting to Other Units

func convert(to: UnitType)

Converts the measurement to the specified unit.

func converted(to: UnitType)

Returns a new measurement created by converting to the specified unit.

Describing a Measurement

var description: String

A textual description of the measurement.

var debugDescription: String

A textual description of the measurement suitable for debugging.

var customMirror: Mirror

A mirror that reflects the date interval.

var hashValue: Int

The computed hash value for the date interval.

Using Reference Types

class NSMeasurement

An object representing a numeric quantity with a unit of measure that bridges to Measurement; use NSMeasurement when you need reference semantics or other Foundation-specific behavior.

typealias Measurement.ReferenceType

An alias for this value type's equivalent reference type.

Instance Methods

See Also

First Steps

class Unit

An abstract class representing a unit of measure.

class Dimension

An abstract class representing a dimensional unit of measure.