init(activityType:start:end:)
Instantiates a new workout.
Declaration
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 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
A workout activity.
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
Creating workouts
init(activityType:start:end:duration:totalEnergyBurned:totalDistance:metadata:)init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:metadata:)init(activityType:start:end:duration:totalEnergyBurned:totalDistance:device:metadata:)init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:device:metadata:)init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:totalFlightsClimbed:device:metadata:)init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:totalSwimmingStrokeCount:device:metadata:)