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

# predicateForObjects(from:)

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

## Declaration

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

## Parameters

- `workout`: The workout you are searching for.

## Mentioned in

Adding samples to a workout

## Return Value

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

## Discussion

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.

## See Also

### Related Documentation

- [add(_:to:completion:)](healthkit/hkhealthstore/add(_:to:completion:).md)

### Creating workout predicates

- [predicateForWorkouts(with:)](healthkit/hkquery/predicateforworkouts(with:).md)
- [predicateForWorkouts(activityPredicate:)](healthkit/hkquery/predicateforworkouts(activitypredicate:).md)
- [predicateForWorkouts(with:duration:)](healthkit/hkquery/predicateforworkouts(with:duration:).md)
- [predicateForWorkouts(operatorType:quantityType:averageQuantity:)](healthkit/hkquery/predicateforworkouts(operatortype:quantitytype:averagequantity:).md)
- [predicateForWorkouts(operatorType:quantityType:maximumQuantity:)](healthkit/hkquery/predicateforworkouts(operatortype:quantitytype:maximumquantity:).md)
- [predicateForWorkouts(operatorType:quantityType:minimumQuantity:)](healthkit/hkquery/predicateforworkouts(operatortype:quantitytype:minimumquantity:).md)
- [predicateForWorkouts(operatorType:quantityType:sumQuantity:)](healthkit/hkquery/predicateforworkouts(operatortype:quantitytype:sumquantity:).md)
- [predicateForWorkouts(with:totalDistance:)](healthkit/hkquery/predicateforworkouts(with:totaldistance:).md)
- [predicateForWorkouts(with:totalEnergyBurned:)](healthkit/hkquery/predicateforworkouts(with:totalenergyburned:).md)
- [predicateForWorkouts(with:totalFlightsClimbed:)](healthkit/hkquery/predicateforworkouts(with:totalflightsclimbed:).md)
- [predicateForWorkouts(with:totalSwimmingStrokeCount:)](healthkit/hkquery/predicateforworkouts(with:totalswimmingstrokecount:).md)
