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 }