---
title: "workoutSession(_:didGenerate:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkworkoutsessiondelegate/workoutsession(_:didgenerate:)"
---

# workoutSession(_:didGenerate:)

Tells the delegate that the system generated a workout event.

## Declaration

```swift
optional func workoutSession(_ workoutSession: HKWorkoutSession, didGenerate event: HKWorkoutEvent)
```

## Parameters

- `workoutSession`: The workout session associated with the event.
- `event`: The event that the system generated. For a list of possible values, see doc://com.apple.healthkit/documentation/HealthKit/HKWorkoutEvent.

## Mentioned in

Receiving Downhill Skiing and Snowboarding Data

## Discussion

Discussion You can save the generated events and use them when creating a HKWorkout object for the session.

## See Also

### Tracking workout sessions

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