<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 3.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKWorkoutSessionDelegate/workoutSession(_:didGenerate:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(pl)HKWorkoutSessionDelegate(im)workoutSession:didGenerateEvent:"
  },
  "title" : "workoutSession(_:didGenerate:)"
}
-->

# workoutSession(_:didGenerate:)

Tells the delegate that the system generated a workout event.

```
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 [`HKWorkoutEvent`](/documentation/HealthKit/HKWorkoutEvent).

## Discussion

You can save the generated events and use them when creating a [`HKWorkout`](/documentation/HealthKit/HKWorkout) object for the session.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)