An object representing an important event during a workout.


class HKWorkoutEvent : NSObject


You can use workout events to toggle a workout between an active and an inactive state, or to mark points of interest during a workout.

Workouts start in an active state. A pause event switches it to an inactive state; a resume event switches it back to an active state. Adding a pause event when the workout is already inactive, or a resume event when the workout is already active, does not affect the workout’s state. These events are ignored.

The lap, segment, and marker events are used to identify periods of interest during a workout. Use lap events to partition a workout into segments of equal distance. Segment events mark important periods during the workout, while markers identify important points in time.


Creating Workout Events

init(type: HKWorkoutEventType, dateInterval: DateInterval, metadata: [String : Any]?)

Instantiates and returns a new workout event with the specified type, date interval, and metadata.

Getting Property Data

var dateInterval: DateInterval

The time and duration of the event.

var type: HKWorkoutEventType

The type of workout event.

var metadata: [String : Any]?

The metadata associated with the workout event.

Determining the Event Type

enum HKWorkoutEventType

Constants that represent events occurring during a workout.


init(type: HKWorkoutEventType, date: Date)

Instantiates and returns a new workout event with the specified type and date.

init(type: HKWorkoutEventType, date: Date, metadata: [String : Any])

Instantiates and returns a new workout event with the specified type, date, and metadata.

var date: Date

The time when the transition occurred.



Inherits From

See Also


Using Workout Samples

Record a physical activity using workout samples.

class HKWorkout

A workout sample that stores information about a single physical activity.

class HKWorkoutBuilder

A builder object that incrementally constructs a workout.

class HKWorkoutType

A type that identifies samples that store information about a workout.

let HKWorkoutTypeIdentifier: String

The workout type identifier.

enum HKWorkoutActivityType

The type of activity performed during a workout.