Contents

workoutSession(_:didFailWithError:)

Tells the delegate that the session failed with an error.

Declaration

func workoutSession(_ workoutSession: HKWorkoutSession, didFailWithError error: any Error)

Parameters

  • workoutSession:

    The workout session that failed.

  • error:

    An error object describing the failure.

Discussion

When the state of the workout session changes due to an error, HealthKit always calls this method before calling the workoutSession(_:didChangeTo:from:date:) method.

For example, if a second app starts a workout session, HealthKit calls the current session’s workoutSession(_:didFailWithError:) method. Next, it changes current session’s state to the HKWorkoutSessionState.ended value. Finally, HealthKit calls the current session’s workoutSession(_:didChangeTo:from:date:) method.

See Also

Tracking workout sessions