Is it possible to set TotalDistance for the sorts of HKSampleQueryDescriptor?
In HKSampleQuery, I can set TotalDistance as follows.
let sort = NSSortDescriptor(key: HKWorkoutSortIdentifierTotalDistance, ascending: false)
let type = HKWorkoutType.workoutType()
let query = HKSampleQuery(sampleType: type, predicate: nil, limit: 0, sortDescriptors: [sort] ){
(query, results, error) -> Void in
}
I want to create a SortDescriptor for HKSampleQueryDescriptor.
When I set HKWorkout.totalDistance to parameter in SortDescriptor, the compile error occurred.
let sort = SortDescriptor(\HKWorkout.totalDistance, order: .forward)
// Error: "No exact matches in call to initializer"
I know that HKWorkout.totalDistance is deprecated.
Isn't it recommended to set TotalDistance to sort?
I'm expecting that on iOS 16, I can get my workouts in heart rate order, is this a mistake?