workoutSession(_:didChangeTo:from:date:)
Tells the delegate that the session’s state changed.
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.