This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func mostRecentWorkouts(for healthStore: HKHealthStore, limit: Int) async throws -> [HKWorkout] { | |
let query = HKSampleQueryDescriptor( | |
predicates: [.workout()], | |
sortDescriptors: [SortDescriptor(\.endDate, order: .reverse)], | |
limit: limit | |
) | |
return try await query.result(for: healthStore) | |
} |