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

# predicateForObjects(from:)

Returns a predicate that matches any objects that have been associated with the provided workout.

```
class func predicateForObjects(from workout: HKWorkout) -> NSPredicate
```

## Parameters

`workout`

The workout you are searching for.

## Return Value

A predicate that matches any objects that have been added to the provided workout.

## Discussion

Use this convenience method to create a predicate that matches all the HealthKit objects for a given workout. The following sample uses both the convenience method and a predicate format string to create equivalent predicates.

```swift
let workoutObjects = HKQuery.predicateForObjectsFromWorkout(workout)
 
let explicitWorkoutObjects =
    NSPredicate(format: "%K == %@", HKPredicateKeyPathWorkout, workout)
```

## See Also

[`-  addSamples:toWorkout:completion:`](/documentation/HealthKit/HKHealthStore/add(_:to:completion:))

Associates the provided samples with the specified workout.



---

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)