Instance Method

workoutSession(_:didChangeTo:from:date:)

Tells the delegate that the session’s state has changed.

Required.

Declaration

func workoutSession(_ workoutSession: HKWorkoutSession, didChangeTo toState: HKWorkoutSessionState, from fromState: HKWorkoutSessionState, date: Date)

Parameters

workoutSession

The workout session that changed.

toState

The session’s new state. For a list of possible values, see HKWorkoutSessionState.

fromState

The session’s previous state. For a list of possible values, see HKWorkoutSessionState.

date

A date object indicating when the state change occurred.

Discussion

If your application is suspended, the delegate receives this call after the application resumes. This means you may receive the notification long after the state changed. Check the date parameter to determine when the state change actually occurred.

For a list of possible session states, see HKWorkoutSessionState.

See Also

Tracking Workout Sessions

func workoutSession(HKWorkoutSession, didFailWithError: Error)

Tells the delegate that the session has failed with an error.

Required.

func workoutSession(HKWorkoutSession, didGenerate: HKWorkoutEvent)

Tells the delegate that the system has generated a workout event.