Sometimes my users would like to update an Apple Health workout after it's been saved. For example, maybe they forgot to end the workout and want to trim it. Or maybe it was a treadmill workout, and they want to add the stats from the treadmill.
The way I've attempted to do this in the past is to create a new HKWorkoutBuilder, call beginCollection, and add the data the user wants to keep from the original workout (events, activities, samples, workout route, and metadata with an incremented HKMetadataKeySyncIdentifier.
After all that, I call endCollection() and finishWorkout() on the builder.
Is this the right way to go about it?
For trimming a workout, it would be great to have a way to just duplicate a workout with an adjusted start and end time and have HealthKit do all the hard work of trimming data.