---
title: "preferredUnits(for:completion:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkhealthstore/preferredunits(for:completion:)"
---

# preferredUnits(for:completion:)

Returns the user’s preferred units for the given quantity types.

## Declaration

```swift
func preferredUnits(for quantityTypes: Set<HKQuantityType>, completion: @escaping @Sendable ([HKQuantityType : HKUnit], (any Error)?) -> Void)
```

```swift
func preferredUnits(for quantityTypes: Set<HKQuantityType>) async throws -> [HKQuantityType : HKUnit]
```

## Parameters

- `quantityTypes`: A set of doc://com.apple.healthkit/documentation/HealthKit/HKQuantityType identifiers. These identifiers represent the quantity types to be examined. Before calling this method, your app must request read or share access to all the types in this set.
- `completion`: A block that this method calls as soon as it finishes looking up the preferred units. This block is passed the following parameters:

## Discussion

Discussion This method runs asynchronously. As soon as it finishes looking up the preferred units, it calls the completion block on an anonymous background queue. By default, the preferred units are based on the device’s current locale. For example, in the US, the preferred units for the bodyMass identifier are pounds. Other regions may use kilograms or stones. However, users can change their preferred units in the Health app at any time. Your app should present HealthKit data using the current preferred units (see the bloodGlucose results identifier for an exception). You should also observe the HKUserPreferencesDidChange notification, and update the user interface whenever the user changes his or her preferred units. note: The results returned by this method are based on your app’s permissions: If you have never requested access for a type, this method returns an authorization not determined error. If the user denied access to a type, this method returns the default units for the device’s current locale for that type. If the user granted either read or share access, this method returns the current preferred units for that type (which may or may not be the default units).

## See Also

### Accessing the preferred units

- [preferredWorkoutZoneConfiguration(for:)](healthkit/hkhealthstore/preferredworkoutzoneconfiguration(for:).md)
- [HKUserPreferencesDidChange](foundation/nsnotification/name-swift.struct/hkuserpreferencesdidchange.md)
