From 36400d1f790833e74da50993933507f7c3286362 Mon Sep 17 00:00:00 2001 From: Trey t Date: Fri, 23 Jun 2023 22:11:49 -0500 Subject: [PATCH] WIP --- Werkout_watch Watch App/WatchMainViewModel.swift | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Werkout_watch Watch App/WatchMainViewModel.swift b/Werkout_watch Watch App/WatchMainViewModel.swift index 966e594..bb85951 100644 --- a/Werkout_watch Watch App/WatchMainViewModel.swift +++ b/Werkout_watch Watch App/WatchMainViewModel.swift @@ -177,11 +177,13 @@ extension WatchMainViewModel: HKWorkoutSessionDelegate, HKLiveWorkoutBuilderDele } switch quantityType { case HKQuantityType.quantityType(forIdentifier: .heartRate): - let statistics = workoutBuilder.statistics(for: quantityType) - let heartRateUnit = HKUnit.count().unitDivided(by: HKUnit.minute()) - let value = statistics!.mostRecentQuantity()?.doubleValue(for: heartRateUnit) - heartValue = Int(Double(round(1 * value!) / 1)) - print("[workoutBuilder] Heart Rate: \(String(describing: heartValue))") + DispatchQueue.main.async() { + let statistics = workoutBuilder.statistics(for: quantityType) + let heartRateUnit = HKUnit.count().unitDivided(by: HKUnit.minute()) + let value = statistics!.mostRecentQuantity()?.doubleValue(for: heartRateUnit) + self.heartValue = Int(Double(round(1 * value!) / 1)) + print("[workoutBuilder] Heart Rate: \(String(describing: self.heartValue))") + } default: return }