Type Method

predicateForObjectsFromWorkout:

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

Declaration

+ (NSPredicate *)predicateForObjectsFromWorkout:(HKWorkout *)workout;

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.

NSPredicate *workoutObjects = [HKQuery predicateForObjectsFromWorkout:workout];
 
NSPredicate *explicitWorkoutObjects =
[NSPredicate predicateWithFormat:@"%K == %@",
 HKPredicateKeyPathWorkout,
 workout];

See Also

Creating Workout Predicates

+ 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.

+ predicateForWorkoutsWithWorkoutActivityType:

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