addWorkoutActivity(_:completion:)
Adds a workout activity to the workout builder.
Declaration
func addWorkoutActivity(_ workoutActivity: HKWorkoutActivity, completion: @escaping @Sendable (Bool, (any Error)?) -> Void)func addWorkoutActivity(_ workoutActivity: HKWorkoutActivity) async throwsParameters
- workoutActivity:
The workout activity to add.
- completion:
A callback handler that the system calls after adding the workout activity. The system calls the callback handler on an anonymous background queue.
The callback handler takes the following parameters:
Discussion
You can call this method repeatedly to incrementally add activities to the builder. Calling this method after calling finishWorkout(completion:) fails with an error.
If you add an HKWorkoutActivity object that doesn’t have an endDate, you can set the end date by calling updateActivity(uuid:end:completion:).