---
title: "removeItem(_:named:from:context:replyHandler:)"
framework: fskit
role: symbol
role_heading: Instance Method
path: "fskit/fsvolume/handler/removeitem(_:named:from:context:replyhandler:)"
---

# removeItem(_:named:from:context:replyHandler:)

Removes an existing item from a given directory.

## Declaration

```swift
func removeItem(_ item: FSItem, named name: FSFileName, from directory: FSItem, context: FSContext, replyHandler reply: @escaping @Sendable (FSRemoveItemResult?, (any Error)?) -> Void)
```

```swift
func removeItem(_ item: FSItem, named name: FSFileName, from directory: FSItem, context: FSContext) async throws -> FSRemoveItemResult
```

## Parameters

- `item`: The item to remove.
- `name`: The name of the item to remove.
- `directory`: The directory from which to remove the item.
- `context`: An object that enables context-aware file system decisions throughout the operation.
- `reply`: A block or closure to indicate success or failure. If removal succeeds, pass an instance of doc://FSKit/documentation/FSKit/FSRemoveItemResult containing the doc://FSKit/documentation/FSKit/FSItem/Attributes of the removed item, the updated doc://FSKit/documentation/FSKit/FSItem/Attributes of the parent directory, and the volume’s updated free space, along with a nil error. If removal fails, pass the relevant error as the second parameter; FSKit ignores the doc://FSKit/documentation/FSKit/FSRemoveItemResult instance in this case. For an async Swift implementation, there’s no reply handler; simply return the result instance or throw an error.

## Discussion

Discussion Don’t actually remove the item object itself in your implementation; instead, only remove the given item name from the given directory. Remove and deallocate the item in reclaimItem(_:replyHandler:).

## See Also

### Working with items

- [createItem(named:type:in:attributes:context:replyHandler:)](fskit/fsvolume/handler/createitem(named:type:in:attributes:context:replyhandler:).md)
- [FSFileName](fskit/fsfilename.md)
- [FSItem.ItemType](fskit/fsitem/itemtype.md)
- [FSItem.SetAttributesRequest](fskit/fsitem/setattributesrequest.md)
- [FSCreateItemResult](fskit/fscreateitemresult.md)
- [lookupItem(named:in:context:replyHandler:)](fskit/fsvolume/handler/lookupitem(named:in:context:replyhandler:).md)
- [FSLookupItemResult](fskit/fslookupitemresult.md)
- [FSRemoveItemResult](fskit/fsremoveitemresult.md)
- [renameItem(_:inDirectory:named:to:inDirectory:overItem:context:replyHandler:)](fskit/fsvolume/handler/renameitem(_:indirectory:named:to:indirectory:overitem:context:replyhandler:).md)
- [FSRenameItemResult](fskit/fsrenameitemresult.md)
- [reclaimItem(_:replyHandler:)](fskit/fsvolume/handler/reclaimitem(_:replyhandler:).md)
