<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKQuery/predicateForObjects(from:)-89b4t",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKQuery(cm)predicateForObjectsFromSources:"
  },
  "title" : "predicateForObjects(from:)"
}
-->

# predicateForObjects(from:)

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

```
class func predicateForObjects(from sources: Set<HKSource>) -> NSPredicate
```

## Parameters

`sources`

A set of sources that have saved data to the HealthKit store.

## Return Value

A predicate that matches all the objects created by any of the provided sources.

## Discussion

Use this convenience method to create a predicate that finds all the objects from a specified set of apps or devices. The following sample uses both the convenience method and a predicate format string to create equivalent predicates.

```swift
let fromSources = HKQuery.predicateForObjectsFromSources(sources)
 
let explicitFromSources =
    NSPredicate(format: "%K IN %@", HKPredicateKeyPathSource, sources)
```

## See Also

[`source`](/documentation/HealthKit/HKObject/source)

A HealthKit source, representing the app or device that created this object.

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

A query that returns a list of sources, such as apps and devices, that have saved matching queries to the HealthKit store.



---

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)