---
title: "lookupItem(named:in:context:replyHandler:)"
framework: fskit
role: symbol
role_heading: Instance Method
path: "fskit/fsvolume/handler/lookupitem(named:in:context:replyhandler:)"
---

# lookupItem(named:in:context:replyHandler:)

Looks up an item within a directory.

## Declaration

```swift
func lookupItem(named name: FSFileName, in directory: FSItem, context: FSContext, replyHandler reply: @escaping @Sendable (FSLookupItemResult?, (any Error)?) -> Void)
```

```swift
func lookupItem(named name: FSFileName, in directory: FSItem, context: FSContext) async throws -> FSLookupItemResult
```

## Parameters

- `name`: The name of the item to look up.
- `directory`: The directory in which to look up 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 lookup succeeds, pass an instance of doc://FSKit/documentation/FSKit/FSLookupItemResult containing the found doc://FSKit/documentation/FSKit/FSItem, its doc://FSKit/documentation/FSKit/FSFileName (as saved within the file system), and its doc://FSKit/documentation/FSKit/FSItem/Attributes, along with a nil error. If lookup fails, pass the relevant error as the second parameter; FSKit ignores the doc://FSKit/documentation/FSKit/FSLookupItemResult 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 If no item matching name exists in the directory indicated by directory, complete the request with an error with a domain of NSPOSIXErrorDomain and a code of ENOENT. tip: The FSFileName sent back to the caller may differ from the name parameter. This flexibility allows your implementation to handle case-insensitive and case-sensitive file systems. It might also be the case that name uses a composed Unicode string, but the name maintained by the file system and provided to the caller is uncomposed Unicode.

## 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)
- [FSLookupItemResult](fskit/fslookupitemresult.md)
- [removeItem(_:named:from:context:replyHandler:)](fskit/fsvolume/handler/removeitem(_:named:from:context:replyhandler:).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)
