deleteItem(withIdentifier:completionHandler:)
Permanently deletes an item from the trash.
Declaration
func deleteItem(withIdentifier itemIdentifier: NSFileProviderItemIdentifier, completionHandler: @escaping @Sendable ((any Error)?) -> Void)func deleteItem(withIdentifier itemIdentifier: NSFileProviderItemIdentifier) async throwsParameters
- itemIdentifier:
The item’s persistent identifier.
- completionHandler:
A block that takes the following parameters:
errorAn error object. If an error occurs, pass in an object that describes the error; otherwise, set it to
nil.
Discussion
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 capability.
See Also
Handling actions
Providing support for user-driven actionscreateDirectory(withName:inParentItemIdentifier:completionHandler:)importDocument(at:toParentItemIdentifier:completionHandler:)renameItem(withIdentifier:toName:completionHandler:)reparentItem(withIdentifier:toParentItemWithIdentifier:newName:completionHandler:)setFavoriteRank(_:forItemIdentifier:completionHandler:)setLastUsedDate(_:forItemIdentifier:completionHandler:)setTagData(_:forItemIdentifier:completionHandler:)trashItem(withIdentifier:completionHandler:)untrashItem(withIdentifier:toParentItemIdentifier:completionHandler:)