---
title: "init(activityType:start:end:)"
framework: healthkit
role: symbol
role_heading: Initializer
path: "healthkit/hkworkout/init(activitytype:start:end:)"
---

# init(activityType:start:end:)

Instantiates a new workout.

## Declaration

```swift
convenience init(activityType workoutActivityType: HKWorkoutActivityType, start startDate: Date, end endDate: Date)
```

## Parameters

- `workoutActivityType`: The type of activity being performed during the workout. For a list of possible activity types, see doc://com.apple.healthkit/documentation/HealthKit/HKWorkoutActivityType.
- `startDate`: The date and time when the activity started.
- `endDate`: The date and time when the activity ended. This date must be equal to or later than the start date.

## Return Value

Return Value A workout activity.

## Discussion

Discussion The workout’s duration is calculated from its start and end times. The workout’s total distance, total energy burned, workout events, device, and metadata are all set to nil.

## See Also

### Related Documentation

- [workoutActivityType](healthkit/hkworkout/workoutactivitytype.md)
- [totalDistance](healthkit/hkworkout/totaldistance.md)
- [duration](healthkit/hkworkout/duration.md)
- [metadata](healthkit/hkobject/metadata.md)
- [totalEnergyBurned](healthkit/hkworkout/totalenergyburned.md)
- [workoutEvents](healthkit/hkworkout/workoutevents.md)

### Creating workouts

- [init(activityType:start:end:duration:totalEnergyBurned:totalDistance:metadata:)](healthkit/hkworkout/init(activitytype:start:end:duration:totalenergyburned:totaldistance:metadata:).md)
- [init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:metadata:)](healthkit/hkworkout/init(activitytype:start:end:workoutevents:totalenergyburned:totaldistance:metadata:).md)
- [init(activityType:start:end:duration:totalEnergyBurned:totalDistance:device:metadata:)](healthkit/hkworkout/init(activitytype:start:end:duration:totalenergyburned:totaldistance:device:metadata:).md)
- [init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:device:metadata:)](healthkit/hkworkout/init(activitytype:start:end:workoutevents:totalenergyburned:totaldistance:device:metadata:).md)
- [init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:totalFlightsClimbed:device:metadata:)](healthkit/hkworkout/init(activitytype:start:end:workoutevents:totalenergyburned:totaldistance:totalflightsclimbed:device:metadata:).md)
- [init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:totalSwimmingStrokeCount:device:metadata:)](healthkit/hkworkout/init(activitytype:start:end:workoutevents:totalenergyburned:totaldistance:totalswimmingstrokecount:device:metadata:).md)
