A data source that automatically provides live data from an active workout session.


class HKLiveWorkoutDataSource : NSObject


Creating a Live Data Source

init(healthStore: HKHealthStore, workoutConfiguration: HKWorkoutConfiguration?)

Creates a new data source based on the provided workout configuration.

var typesToCollect: Set<HKQuantityType>

The quantity type samples that the data source automatically sends to the workout builder.

Calculating Statistics

func enableCollection(for: HKQuantityType, predicate: NSPredicate?)

Begins automatically calculating statistics for samples that match the quantity type and predicate.

func disableCollection(for: HKQuantityType)

Stops automatically calculating statistics for the quantity type.


Inherits From

Conforms To

See Also


Running Workout Sessions

Track a workout on Apple Watch.

SpeedySloth: Creating a Workout

Use the Workout Builder API to start, stop, and to save workouts on Apple Watch.

class HKWorkoutSession

A session that tracks the user’s workout on Apple Watch.

class HKWorkoutConfiguration

An object that contains configuration information about a workout session.

enum HKWorkoutSessionState

A workout session’s state.

class HKLiveWorkoutBuilder

A builder object that constructs a workout incrementally based on live data from an active workout session.