<!--
{
  "availability" : [
    "iOS: 11.0.0 -",
    "iPadOS: 11.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FileProvider",
  "identifier" : "/documentation/FileProvider/NSFileProviderExtension/deleteItem(withIdentifier:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "File Provider",
      "FileProvider"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileProviderExtension(im)deleteItemWithIdentifier:completionHandler:"
  },
  "title" : "deleteItem(withIdentifier:completionHandler:)"
}
-->

# deleteItem(withIdentifier:completionHandler:)

Permanently deletes an item from the trash.

```
func deleteItem(withIdentifier itemIdentifier: NSFileProviderItemIdentifier, completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

```
func deleteItem(withIdentifier itemIdentifier: NSFileProviderItemIdentifier) async throws
```

## Parameters

`itemIdentifier`

The item’s persistent identifier.

`completionHandler`

A block that takes the following parameters:

- `error`: An error object. If an error occurs, pass in an object that describes the error; otherwise, set it to `nil`.

## Discussion

> Important:
> You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration:
> 
> ```swift
> func deleteItem(withIdentifier itemIdentifier: NSFileProviderItemIdentifier) async throws
> ```
> 
> For information about concurrency and asynchronous code in Swift, see <doc://com.apple.documentation/documentation/Swift/calling-objective-c-apis-asynchronously>.

This method is called when the user deletes an item from the trash. Override this method to remove the item from the working set and delete it from disk (if necessary). The item should no longer be accessible.

Your implementation should return immediately. Call the completion handler before performing any network activity or other long-running tasks. Defer these tasks to the background.

The user’s ability to delete an item is controlled by the item’s [`allowsDeleting`](/documentation/FileProvider/NSFileProviderItemCapabilities/allowsDeleting) capability.

---

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)