Contents

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 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

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