<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKQuery/predicateForObjects(withDeviceProperty:allowedValues:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKQuery(cm)predicateForObjectsWithDeviceProperty:allowedValues:"
  },
  "title" : "predicateForObjects(withDeviceProperty:allowedValues:)"
}
-->

# predicateForObjects(withDeviceProperty:allowedValues:)

Returns a predicate that matches all objects created by devices with the specified properties.

```
class func predicateForObjects(withDeviceProperty key: String, allowedValues: Set<String>) -> NSPredicate
```

## Parameters

`key`

A string specifying the device’s property. For a list of valid keys, see Valid Device Property Keys.

`allowedValues`

A set of strings. These strings represent the target property values.

## Return Value

A predicate that matches all objects created by a device whose specified property matches one of the allowed values.

## Discussion

Use this convenience method to create a predicate that finds all the objects saved by matching devices. These predicates let you match multiple values for a single property. For example, you can create a single predicate that matches a number of different `manufacturer` values.

The following sample shows how to create a predicate that matches a list of device model names.

```objc
NSPredicate *fromDevices = [HKQuery predicateForObjectsWithDeviceProperty:HKDevicePropertyKeyModel allowedValues:modelNames];
```

## Topics

### Valid Device Property Keys

Use these keys to create predicates that match the specified device property.

[`HKDevicePropertyKeyName`](/documentation/HealthKit/HKDevicePropertyKeyName)

The device’s name.

[`HKDevicePropertyKeyManufacturer`](/documentation/HealthKit/HKDevicePropertyKeyManufacturer)

The device’s manufacturer.

[`HKDevicePropertyKeyModel`](/documentation/HealthKit/HKDevicePropertyKeyModel)

The device’s model.

[`HKDevicePropertyKeyHardwareVersion`](/documentation/HealthKit/HKDevicePropertyKeyHardwareVersion)

The device’s hardware version.

[`HKDevicePropertyKeyFirmwareVersion`](/documentation/HealthKit/HKDevicePropertyKeyFirmwareVersion)

The device’s firmware version.

[`HKDevicePropertyKeySoftwareVersion`](/documentation/HealthKit/HKDevicePropertyKeySoftwareVersion)

The device’s software version.

[`HKDevicePropertyKeyLocalIdentifier`](/documentation/HealthKit/HKDevicePropertyKeyLocalIdentifier)

A unique identifier for the device on the hardware running the app. For more information, see [`localIdentifier`](/documentation/HealthKit/HKDevice/localIdentifier).

[`HKDevicePropertyKeyUDIDeviceIdentifier`](/documentation/HealthKit/HKDevicePropertyKeyUDIDeviceIdentifier)

The device’s UDI Device Identifier.



---

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)