<!--
{
  "availability" : [
    "macOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FSKit",
  "identifier" : "/documentation/FSKit/FSVolume/Handler/removeItem(_:named:from:context:replyHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "FSKit"
    ],
    "preciseIdentifier" : "c:objc(pl)FSVolumeHandler(im)removeItem:named:fromDirectory:context:replyHandler:"
  },
  "title" : "removeItem(_:named:from:context:replyHandler:)"
}
-->

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

Removes an existing item from a given directory.

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

```
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 [`FSRemoveItemResult`](/documentation/FSKit/FSRemoveItemResult) containing the [`FSItem.Attributes`](/documentation/FSKit/FSItem/Attributes) of the removed item, the updated [`FSItem.Attributes`](/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 [`FSRemoveItemResult`](/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

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:)`](/documentation/FSKit/FSVolume/Handler/reclaimItem(_:replyHandler:)).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)