---
title: "accommodatePresentedItemDeletion(completionHandler:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsfilepresenter/accommodatepresenteditemdeletion(completionhandler:)"
---

# accommodatePresentedItemDeletion(completionHandler:)

Tells your object that its presented item is about to be deleted.

## Declaration

```swift
optional func accommodatePresentedItemDeletion(completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
optional func accommodatePresentedItemDeletion() async throws
```

## Parameters

- `completionHandler`: The https://developer.apple.com/library/archive/documentation/General/Conceptual/DevPedia-CocoaCore/Block.html#//apple_ref/doc/uid/TP40008195-CH3 to call after updating your data structures. Pass nil to the block’s errorOrNil parameter if you were able to successfully prepare for the deletion of the item. Pass an error object if your object could not prepare itself properly.

## Discussion

Discussion A file coordinator calls this method when your object’s presented item is about to be deleted. You can use this method to perform any actions that are needed to prepare for the deletion. For example, document objects typically use this method to close the document. important: If you implement this method, you must execute the block in the completionHandler parameter at the end of your implementation. The system waits for you to execute that block before allowing the other object to delete the file or directory. Therefore, failure to execute the block could stall threads in your application or other processes.

## See Also

### Handling Changes to Files

- [savePresentedItemChanges(completionHandler:)](foundation/nsfilepresenter/savepresenteditemchanges(completionhandler:).md)
- [presentedItemDidMove(to:)](foundation/nsfilepresenter/presenteditemdidmove(to:).md)
- [presentedItemDidChange()](foundation/nsfilepresenter/presenteditemdidchange().md)
