Instance Property


The workout’s duration.


var duration: TimeInterval { get }


A workout’s duration can be specified in one of three ways. The init(activityType:start:end:) method uses the time interval between the provided start and end dates. The init(activityType:start:end:duration:totalEnergyBurned:totalDistance:metadata:) method sets the duration to the provided value. And the init(activityType:start:end:workoutEvents:totalEnergyBurned:totalDistance:metadata:) method calculates the total active duration based on the start and end dates and the workout events.

See Also

Accessing Property Data

var totalDistance: HKQuantity?

The total distance traveled during the workout.

var totalEnergyBurned: HKQuantity?

The total active energy burned during the workout.

var workoutActivityType: HKWorkoutActivityType

The type of activity performed during the workout.

var workoutEvents: [HKWorkoutEvent]?

An array of workout event objects.

var totalFlightsClimbed: HKQuantity?

The total number of flights of stairs climbed during the workout.

var totalSwimmingStrokeCount: HKQuantity?

The total stroke count for the workout.