---
title: "workoutSession(_:didChangeTo:from:date:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkworkoutsessiondelegate/workoutsession(_:didchangeto:from:date:)"
---

# workoutSession(_:didChangeTo:from:date:)

Tells the delegate that the session’s state changed.

## Declaration

```swift
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 doc://com.apple.healthkit/documentation/HealthKit/HKWorkoutSessionState.
- `fromState`: The session’s previous state. For a list of possible values, see doc://com.apple.healthkit/documentation/HealthKit/HKWorkoutSessionState.
- `date`: A date object indicating when the state change occurred.

## Discussion

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

- [workoutSession(_:didFailWithError:)](healthkit/hkworkoutsessiondelegate/workoutsession(_:didfailwitherror:).md)
- [workoutSession(_:didGenerate:)](healthkit/hkworkoutsessiondelegate/workoutsession(_:didgenerate:).md)
- [workoutSession(_:didBeginActivityWith:date:)](healthkit/hkworkoutsessiondelegate/workoutsession(_:didbeginactivitywith:date:).md)
- [workoutSession(_:didEndActivityWith:date:)](healthkit/hkworkoutsessiondelegate/workoutsession(_:didendactivitywith:date:).md)
