<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "HealthKit",
  "identifier" : "/documentation/HealthKit/HKHealthStore/deleteObjects(of:predicate:withCompletion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "HealthKit"
    ],
    "preciseIdentifier" : "c:objc(cs)HKHealthStore(im)deleteObjectsOfType:predicate:withCompletion:"
  },
  "title" : "deleteObjects(of:predicate:withCompletion:)"
}
-->

# deleteObjects(of:predicate:withCompletion:)

Deletes objects saved by this application that match the provided type and predicate.

```
func deleteObjects(of objectType: HKObjectType, predicate: NSPredicate, withCompletion completion: @escaping @Sendable (Bool, Int, (any Error)?) -> Void)
```

## Parameters

`objectType`

The type of object to be deleted.

`predicate`

A predicate used to filter the objects to be deleted. This method only deletes objects that match the predicate.

`completion`

A block that this method calls as soon as the delete operation is complete. This block is passed the following parameters:

- success: A Boolean value. This parameter contains <doc://com.apple.documentation/documentation/Swift/true> if the objects were successfully deleted; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.
- deletedObjectCount: The number of objects deleted.
- error: An error object. If an error occurred, this object contains information about the error; otherwise, it is set to `nil`.

## Discussion

Your app can delete only those objects that it has previously saved to the HealthKit store. If the user revokes sharing permission for an object type, you can no longer delete those objects. This method operates asynchronously. As soon as the delete operation is finished, it calls the completion block on a background queue.

If your app has not requested permission to share an object’s data type, the method fails with an [`HKError.Code.errorAuthorizationNotDetermined`](/documentation/HealthKit/HKError/Code/errorAuthorizationNotDetermined) error. If your app has been denied permission to share an object’s data type, it fails with an [`HKError.Code.errorAuthorizationDenied`](/documentation/HealthKit/HKError/Code/errorAuthorizationDenied) error. When deleting multiple objects, if any object cannot be deleted, none of them are deleted.

HealthKit stores temporary [`HKDeletedObject`](/documentation/HealthKit/HKDeletedObject) entries, letting you query for recently deleted objects. However, the deleted objects are periodically removed to save storage space. If you want your app to receive notifications about all the deleted objects, set up an observer query, and enable it for background delivery. In the background query’s update handler, create an anchored object query to gather the list of recently deleted objects.

> Note:
> Although your app can manage only the objects it created and saved, the users can always delete any data they want using the Health app.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)