duration
The activity’s duration, measured in seconds.
Declaration
var duration: TimeInterval { get }Discussion
HealthKit calculates the duration as the elapsed time between the activity’s startDate and endDate, ignoring any pause periods. If an activity is currently in progress, it has a nil-valued endDate. In this case, HealthKit calculates the duration as the time between the startDate and the current time, ignoring any pause periods.