Associates the provided samples with the specified workout.
- iOS 8.0+
- Mac Catalyst 13.0+
- watchOS 2.0+
The workout object you are adding samples to.
A block that this method calls as soon as the add-samples operation is complete. This block is passed the following parameters:
A Boolean value. This parameter contains
trueif the samples were successfully added to workout; otherwise,
An error object. If an error occurred, this object contains information about the error; otherwise, it is set to
This method operates asynchronously. As soon as the add-samples operation is finished, this method calls the completion block on a background queue. You must save the workout to the HealthKit store before you can add any samples to it. You can save the samples before calling this method, but doing so is not required. This method automatically saves any unsaved samples when it successfully adds them to the workout.
To query for all the samples associated with a workout, add the workout to the query’s predicate. For example, the query’s
predicate method creates a predicate object that matches only samples associated with the provided workout.
For more information on workouts and associated samples, see