The requestAuthorization method in WorkoutManager wants to read HR, energy, distance and "activity" information all of which are HKQuantityTypes.
//The quantity types to read from the health store
let typesToRead: Set = [
HKQuantityType.quantityType(forIdentifier: .heartRate)!,
HKQuantityType.quantityType(forIdentifier: .activeEnergyBurned)!,
HKQuantityType.quantityType(forIdentifier: .distanceWalkingRunning)!,
HKQuantityType.quantityType(forIdentifier: .distanceCycling)!,
HKObjectType.activitySummaryType()
]
The documentation for HKObjectType states:
The HKObjectType class is an abstract class. You should never instantiate an HKObjectType object directly. Instead, you always work with one of the following concrete subclasses: ... HKQuantityType
Replacing
HKObjectType.activitySummaryType()
with
HKQuantityType.activitySummaryType()
in the above code doesn't appear to cause any issues with the app. Intuitively, it should work exactly the same since HKQuantityType (being a concrete subclass of HKObjectType) inherits directly from HKObjectType.
Is my understanding correct or have I missed something fundamental?
If my thinking is correct, why is HKObjectType used in the sample code when all of the other set elements use the HKQuantityType subclass?