---
title: "predicateForWorkouts(activityPredicate:)"
framework: healthkit
role: symbol
role_heading: Type Method
path: "healthkit/hkquery/predicateforworkouts(activitypredicate:)"
---

# predicateForWorkouts(activityPredicate:)

Returns a predicate for matching workouts based on the associated workout activities.

## Declaration

```swift
class func predicateForWorkouts(activityPredicate: NSPredicate) -> NSPredicate
```

## Parameters

- `activityPredicate`: A predicate that matches a particular set of workout activities.

## Mentioned in

Dividing a HealthKit workout into activities

## Discussion

Discussion The following example creates a predicate that matches workouts with an associated HKWorkoutActivityType.running activity type. let runningActivityPredicate = HKQuery.predicateForWorkoutActivities(workoutActivityType: .running)

let workoutPredicate = HKQuery.predicateForWorkouts(activityPredicate: runningActivityPredicate)

## See Also

### Creating workout predicates

- [predicateForObjects(from:)](healthkit/hkquery/predicateforobjects(from:)-5irg9.md)
- [predicateForWorkouts(with:)](healthkit/hkquery/predicateforworkouts(with:).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)
