6

I'm developing an app that gives the users the option to track what they ate. One of the features the app suggest is to select a food item as Eaten. When a user does that, I share that info with the HealthKit.

A user can then decide to uncheck that item and return its previous state: Uneaten. I wonder if I can query the previously saved food item and choose to delete it from the HealthKit as it isn't relevant for the user anymore?

UPDATE

Well, After reading almost the entire documentation of HealthKit I found out that HKHealthStore object has a method: deleteObject:withCompletion:. Yet I can't seem to successfully delete an HKCorrelation that stores the food item I previously saved to HealthKit, though the call finish successfully (I can still see the data in the Health App)...

goldengil
  • 1,007
  • 9
  • 25

1 Answers1

7

Use the deleteObject:withCompletion: API to delete the objects you saved. If you saved an HKCorrelation you must delete each of the objects you saved with the correlation as well.

Allan
  • 7,039
  • 1
  • 16
  • 26