---
title: "predicateForObjects(from:)"
framework: healthkit
role: symbol
role_heading: Type Method
path: "healthkit/hkquery/predicateforobjects(from:)-9h87f"
---

# predicateForObjects(from:)

Returns a predicate that matches all the objects that were created by any of the provided devices.

## Declaration

```swift
class func predicateForObjects(from devices: Set<HKDevice>) -> NSPredicate
```

## Parameters

- `devices`: A set of devices that have generated the data for objects stored in the HealthKit store.

## Return Value

Return Value A predicate that matches all the objects that store data generated by any of the provided devices.

## Discussion

Discussion When creating the device objects for this predicate, only pass in values for the parameters you need for your query. HealthKit returns all the devices that match the non-nil parameters. This gives you a great deal of control when it comes to fine tuning your query. For example, setting the localIdentifier and the firmwareVersion parameters lets you query for all the samples generated by a specific device running a specific version of the firmware. Just setting the manufacturer and model casts a much broader net. The following sample uses both the convenience method and a predicate format string to create equivalent predicates.

## See Also

### Creating object predicates

- [predicateForObject(with:)](healthkit/hkquery/predicateforobject(with:).md)
- [predicateForObjects(with:)](healthkit/hkquery/predicateforobjects(with:).md)
- [predicateForObjects(from:)](healthkit/hkquery/predicateforobjects(from:)-7j3p2.md)
- [predicateForObjects(from:)](healthkit/hkquery/predicateforobjects(from:)-89b4t.md)
- [predicateForObjects(withDeviceProperty:allowedValues:)](healthkit/hkquery/predicateforobjects(withdeviceproperty:allowedvalues:).md)
- [predicateForObjects(from:)](healthkit/hkquery/predicateforobjects(from:)-1ar4g.md)
- [predicateForObjects(withMetadataKey:)](healthkit/hkquery/predicateforobjects(withmetadatakey:).md)
- [predicateForObjects(withMetadataKey:allowedValues:)](healthkit/hkquery/predicateforobjects(withmetadatakey:allowedvalues:).md)
- [predicateForObjects(withMetadataKey:operatorType:value:)](healthkit/hkquery/predicateforobjects(withmetadatakey:operatortype:value:).md)
- [predicateForObjectsWithNoCorrelation()](healthkit/hkquery/predicateforobjectswithnocorrelation().md)
