Returns a predicate for matching workouts based on the type of activity.
SDKs
- iOS 8.0+
- Mac Catalyst 13.0+
- watchOS 2.0+
Framework
- Health
Kit
Declaration
+ (NSPredicate *)predicateForWorkoutsWithWorkoutActivityType:(HKWorkout Activity Type)workoutActivityType;
Parameters
workoutActivityType
The type of activity. For a list of valid workout activities, see
HKWorkout
.Activity Type
Return Value
A predicate for matching workouts based on the type of activity.
Discussion
Use this convenience method to create a predicate that matches workouts based on their activity. The following sample uses both the convenience method and a predicate format string to create equivalent predicates.
NSPredicate *workout =
[HKQuery predicateForWorkoutsWithWorkoutActivityType:
HKWorkoutActivityTypeCurling];
NSPredicate *explicitWorkout =
[NSPredicate predicateWithFormat:@"%K == %d",
HKPredicateKeyPathWorkoutType,
HKWorkoutActivityTypeCurling];