---
title: "accommodatePresentedSubitemDeletion(at:completionHandler:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsfilepresenter/accommodatepresentedsubitemdeletion(at:completionhandler:)"
---

# accommodatePresentedSubitemDeletion(at:completionHandler:)

Tells the delegate that some entity wants to delete an item that is inside of a presented directory.

## Declaration

```swift
optional func accommodatePresentedSubitemDeletion(at url: URL, completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

```swift
optional func accommodatePresentedSubitemDeletion(at url: URL) async throws
```

## Parameters

- `url`: The URL of the item being deleted from the presented directory. The item need not be at the top level of the presented directory but may itself be inside a nested subdirectory.
- `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 This method is relevant for applications that present directories. This might occur if the delegate manages the contents of a directory or manages a file that is implemented as a file package. When called, your implementation of this method should take whatever actions needed to update your application to handle the deletion of the specified file. 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 item at the specified URL. Therefore, failure to execute the block could stall threads in your application or in other processes.

## See Also

### Handling Changes to a Presented Directory

- [presentedSubitemDidAppear(at:)](foundation/nsfilepresenter/presentedsubitemdidappear(at:).md)
- [presentedSubitem(at:didMoveTo:)](foundation/nsfilepresenter/presentedsubitem(at:didmoveto:).md)
- [presentedSubitemDidChange(at:)](foundation/nsfilepresenter/presentedsubitemdidchange(at:).md)
