A workout sample that stores information about a single physical activity.
- iOS 8.0+
- Mac Catalyst 13.0+
- watchOS 2.0+
HKWorkout class is a concrete subclass of the
HKSample class. The workout records summary about a single physical activity (for example, the duration, total distance, and total energy burned). It also acts as a container for other
HKSample objects. You can associate any number of samples with a workout, adding fine-grain tracking over the course of the workout. For example, you may want to break a single run into a number of shorter intervals, and then add samples to track the user’s heart rate, energy burned, distance traveled, and steps taken for each interval.
HealthKit supports a wide range of activity types. For a complete list, see
Workouts are mostly immutable. You set their properties when you instantiate the workout, and they can’t change. However, you can continue to add samples to the workouts.
Like many HealthKit classes, the
HKWorkout class should not be subclassed. You may extend workouts by adding metadata with custom keys as appropriate for your app.
For more information, see the methods