Search code examples
iosswifthealthkit

Is it possible to add metadata to an HKWorkout after it's already been saved?


Can I read out an HKworkout and add my own metadata to it, then resave it? If so how? Or can I only pass in metadata when I'm saving the workout?


Solution

  • All HKObjects are immutable (the cannot be edited once saved). The recommend approach to editing an HKObject is to save a new copy with the changes you want to make and to delete the previous copy. You can only do this if your app created the original object, though.