---
title: unitOptions
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/measurementformatter/unitoptions-swift.property
---

# unitOptions

The options for how the unit is formatted.

## Declaration

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

## Discussion

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. If no options are specified, the formatter localizes according to the preferences of the formatter’s 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 units would be formatted as kcal, even if the locale prefers C, and a measurement with 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.

## See Also

### Specifying the Format

- [MeasurementFormatter.UnitOptions](foundation/measurementformatter/unitoptions-swift.struct.md)
- [unitStyle](foundation/measurementformatter/unitstyle.md)
- [locale](foundation/measurementformatter/locale.md)
- [numberFormatter](foundation/measurementformatter/numberformatter.md)
