Type Method

predicateForWorkoutsWithWorkoutActivityType:

Returns a predicate for matching workouts based on the type of activity.

Declaration

+ (NSPredicate *)predicateForWorkoutsWithWorkoutActivityType:(HKWorkoutActivityType)workoutActivityType;

Parameters

workoutActivityType

The type of activity. For a list of valid workout activities, see HKWorkoutActivityType.

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];

See Also

Creating Workout Predicates

+ predicateForObjectsFromWorkout:

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

+ predicateForWorkoutsWithOperatorType:duration:

Returns a predicate for matching workouts based on their duration.

+ predicateForWorkoutsWithOperatorType:totalDistance:

Returns a predicate for matching workouts based on the total distance traveled.

+ predicateForWorkoutsWithOperatorType:totalEnergyBurned:

Returns a predicate for matching workouts based on the total energy burned.

+ predicateForWorkoutsWithOperatorType:totalFlightsClimbed:

Returns a predicate that matches workout samples based on the number of flights climbed.

+ predicateForWorkoutsWithOperatorType:totalSwimmingStrokeCount:

Returns a predicate that matches workout samples based on the number of strokes while swimming.