WIP
This commit is contained in:
@@ -26,18 +26,17 @@ class HealthKitHelper {
|
||||
maxHeartRate: nil,
|
||||
avgHeartRate: nil)
|
||||
|
||||
var completion: ((HealthKitWorkoutData) -> Void)?
|
||||
var completion: ((HealthKitWorkoutData?) -> Void)?
|
||||
|
||||
func getDetails(forHealthKitUUID uuid: UUID, completion: @escaping ((HealthKitWorkoutData) -> Void)) {
|
||||
func getDetails(forHealthKitUUID uuid: UUID, completion: @escaping ((HealthKitWorkoutData?) -> Void)) {
|
||||
self.completion = completion
|
||||
self.returnCount = 0
|
||||
|
||||
print("get details \(uuid.uuidString)")
|
||||
|
||||
let predicate = HKQuery.predicateForObject(with: uuid)
|
||||
let query = HKSampleQuery(sampleType: HKWorkoutType.workoutType(),
|
||||
predicate: predicate,
|
||||
limit: 0,
|
||||
predicate: HKQuery.predicateForObject(with: uuid),
|
||||
limit: HKObjectQueryNoLimit,
|
||||
sortDescriptors: nil)
|
||||
{ (sampleQuery, results, error ) -> Void in
|
||||
|
||||
@@ -45,6 +44,7 @@ class HealthKitHelper {
|
||||
self.shitReturned()
|
||||
self.shitReturned()
|
||||
print( "There was an error while reading the samples: \(queryError.localizedDescription)")
|
||||
self.completion?(nil)
|
||||
} else {
|
||||
for samples: HKSample in results! {
|
||||
let workout: HKWorkout = (samples as! HKWorkout)
|
||||
@@ -54,6 +54,7 @@ class HealthKitHelper {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
healthStore.execute(query)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user