This commit is contained in:
Trey t
2023-06-23 22:11:49 -05:00
parent 662cc77a83
commit 36400d1f79

View File

@@ -177,11 +177,13 @@ extension WatchMainViewModel: HKWorkoutSessionDelegate, HKLiveWorkoutBuilderDele
} }
switch quantityType { switch quantityType {
case HKQuantityType.quantityType(forIdentifier: .heartRate): case HKQuantityType.quantityType(forIdentifier: .heartRate):
let statistics = workoutBuilder.statistics(for: quantityType) DispatchQueue.main.async() {
let heartRateUnit = HKUnit.count().unitDivided(by: HKUnit.minute()) let statistics = workoutBuilder.statistics(for: quantityType)
let value = statistics!.mostRecentQuantity()?.doubleValue(for: heartRateUnit) let heartRateUnit = HKUnit.count().unitDivided(by: HKUnit.minute())
heartValue = Int(Double(round(1 * value!) / 1)) let value = statistics!.mostRecentQuantity()?.doubleValue(for: heartRateUnit)
print("[workoutBuilder] Heart Rate: \(String(describing: heartValue))") self.heartValue = Int(Double(round(1 * value!) / 1))
print("[workoutBuilder] Heart Rate: \(String(describing: self.heartValue))")
}
default: default:
return return
} }