HealthKit Tutorial With Swift: Workouts | Ray Wenderlich

This HealthKit tutorial shows you step by step how to track workouts using the HealthKit APIs by integrating an app with the system’s Health app.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/6992-healthkit-tutorial-with-swift-workouts

There’s a crash when saving workouts. In CreateWorkoutTableViewController, you need to make the callback from save run on the main thread:

    WorkoutDataStore.save(prancerciseWorkout: currentWorkout) { (success, error) in
        DispatchQueue.main.async {
          if success {
            self.dismissAndRefreshWorkouts()
          } else {
            self.displayProblemSavingWorkoutAlert()
          }
        }
    }

@mcintyre1994 Thank you for sharing your solution - much appreciated! :]

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!