A sample that contains a workout’s route data.


class HKWorkoutRoute : HKSeriesSample


When creating a workout route, you do not instantiate the HKWorkoutRoute objects directly. Instead, create a HKWorkoutRouteBuilder object, and provide it with location data throughout the workout. After the workout ends, call the route builder’s finishRoute(with:metadata:completion:) method to create the route. For detailed instructions, see Creating a Workout Route.

The route’s location data is stored as an array of CLLocation objects. Because the route may contain a large number of location objects, use a HKWorkoutRouteQuery object to asynchronously read the location data from the HealthKit store in batches. For more information, see Reading Route Data.

Using Workout Routes

Like many HealthKit classes, the HKWorkoutRoute class should not be subclassed. You can extend HKWorkoutRoute objects by adding custom metadata keys and values to the metadata dictionary when the object is created.


Inherits From

Conforms To

See Also

Route Data

Creating a Workout Route

Record the user’s route during a workout.

Reading Route Data

Access the user’s route for a workout.

class HKWorkoutRouteBuilder

A builder object that incrementally constructs a workout route.

class HKWorkoutRouteQuery

A query to access the location data stored in a workout route.

let HKWorkoutRouteTypeIdentifier: String

A series sample containing location data that defines the route the user took during a workout.

class HKSeriesBuilder

An abstract base class for building series samples.

class HKSeriesSample

An abstract base class that defines samples that contain a series of items.