HealthKit method deleteObjectsOfType ignores type and deletes all
Originator: | ben | ||
Number: | rdar://22977320 | Date Originated: | 2015-10-05 |
Status: | Duplicate/23097982 | Resolved: | false |
Product: | iOS SDK | Product Version: | 9.0 |
Classification: | Serious Bug | Reproducible: | Always |
Summary: The HealthKit method deleteObjectsOfType should allow you to delete objects of a specific HKObjectType that match a predicate. At present, the type is ignored so if you try and delete all "flights climbed" data your app has written in the past 7 days, then it will also delete any other data in the past 7 days that your app has written. Steps to Reproduce: 1. Save a variety of HKSample data of differing HKObjectType to the Health app via the healthStore.saveObject 2. Try and delete a specific set of HKObjectType data from HealthKit via the healthStore.deleteObjectsOfType(type, predicate:, withCompletion:) method 3. Watch as all of the data you logged, regardless of type, is deleted Expected Results: It is expected that only objects of the type specified (that match the predicate) are deleted Actual Results: Any object from your app that matches the predicate is deleted rather than those that match both type and predicate Version: iOS 9.0.2 Notes: Example project demonstrating this issue attached. You'll need to run it and choose "Authenticate With HealthKit" to set up the necessary permissions and then "Save HealthKit data" to save data to the Health app. If you look, you'll see that only the "flights climbed" data has been saved as the deleteObjectsOfType(type: flightsType, etc.) removed not only any existing "flights climbed" data but also the "step count" data that you logged a few lines before. Configuration: iOS 9 Simulator (iPhone 6) Attachments: 'HealthKitTest.zip' was successfully uploaded.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Duplicate of 23097982