---
title: "delete(_:withCompletion:)"
framework: healthkit
role: symbol
role_heading: Instance Method
path: "healthkit/hkhealthstore/delete(_:withcompletion:)-78l1m"
---

# delete(_:withCompletion:)

Deletes the specified object from the HealthKit store.

## Declaration

```swift
func delete(_ object: HKObject, withCompletion completion: @escaping @Sendable (Bool, (any Error)?) -> Void)
```

```swift
func delete(_ object: HKObject) async throws
```

## Parameters

- `object`: An object that this app has previously saved to the HealthKit store.
- `completion`: A block that this method calls as soon as the delete operation is complete. This block is passed the following parameters:

## Discussion

Discussion Your app can delete only those objects that it has previously saved to the HealthKit store. If the user revokes sharing permission, you can no longer delete the object. 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 the object’s data type, the method fails with an HKError.Code.errorAuthorizationNotDetermined error. If your app has been denied permission to share the object’s data type, it fails with an HKError.Code.errorAuthorizationDenied error. HealthKit stores a temporary HKDeletedObject entry, 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 HKAnchoredObjectQuery object to gather the list of recently deleted objects. note: Although your app can manage only the objects it created and saved, users can always delete any data through the Health app.

## See Also

### Working with HealthKit objects

- [delete(_:withCompletion:)](healthkit/hkhealthstore/delete(_:withcompletion:)-17hzm.md)
- [deleteObjects(of:predicate:withCompletion:)](healthkit/hkhealthstore/deleteobjects(of:predicate:withcompletion:).md)
- [earliestPermittedSampleDate()](healthkit/hkhealthstore/earliestpermittedsampledate().md)
- [save(_:withCompletion:)](healthkit/hkhealthstore/save(_:withcompletion:)-6fmtg.md)
- [save(_:withCompletion:)](healthkit/hkhealthstore/save(_:withcompletion:)-47iwb.md)
