How to add HKQuantity to HKWorkout with WorkoutBuilder

At the moment I am working on a running app for the iPhone.

One issue that I have is, that I am building the HKWorkout using the HKWorkoutBuilder according to Apples Documentation.

But I am not able to associate the totalDistance with the workout – mentioned here in the Documentation. totalDistance is nil when I try to read it from the workout – no surprise.

I think I miss something here. Thanks in advance.
Answered by Frameworks Engineer in 668745022
Use addSamples method on HKWorkoutBuilder to add DistanceWalkingRunning samples. This should populate totalDistance.
Accepted Answer
Use addSamples method on HKWorkoutBuilder to add DistanceWalkingRunning samples. This should populate totalDistance.
This seems to work, but doesnt populate totalDistance parameter – at least for me. But I can now get the distance from the associated HKQuantitySample.
And the spot in the HealthApp is still empty.. (Run: 25 Min. | --)
Is that the way to go?



same here. Did you fix it somehow?

How to add HKQuantity to HKWorkout with WorkoutBuilder
 
 
Q