<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.12.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/MeasurementFormatter/unitOptions-swift.property",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMeasurementFormatter(py)unitOptions"
  },
  "title" : "unitOptions"
}
-->

# unitOptions

The options for how the unit is formatted.

```
var unitOptions: MeasurementFormatter.UnitOptions { get set }
```

## Discussion

You can set this property to ensure that the formatter chooses the preferred unit to format for the measurement based on the formatter’s locale. For possible values, see [`MeasurementFormatter.UnitOptions`](/documentation/Foundation/MeasurementFormatter/UnitOptions-swift.struct).

If no options are specified, the formatter localizes according to the preferences of the formatter’s [`locale`](/documentation/Foundation/MeasurementFormatter/locale). For example, a measurement in kilocalories may be formatted as `C` instead of `kcal`, or a measurement in kilometers per hour may be formatted as `miles per hour` for US and UK locales, but `kilometers per hour` for other locales. However, if the `providedUnit` option is specified, a measurement with [`kilocalories`](/documentation/Foundation/UnitEnergy/kilocalories) units would be formatted as `kcal`, even if the locale prefers `C`, and a measurement with [`kilometersPerHour`](/documentation/Foundation/UnitSpeed/kilometersPerHour) units would be formatted as `kilometers per hour` for US and UK locales, even though they prefer `miles per hour`.

> Note:
> `NSMeasurementFormatter` handles the conversion of measurements to the preferred units in a particular locale when this option is specified. For example, if provided a measurement object in kilojoules, the formatter implicitly converts the measurement object to kilocalories and returns the formatted string as the equivalent measurement in kilocalories.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)