---
title: "descendant(matchingIdentifierPath:completion:)"
framework: classkit
role: symbol
role_heading: Instance Method
path: "classkit/clscontext/descendant(matchingidentifierpath:completion:)"
---

# descendant(matchingIdentifierPath:completion:)

Finds the context with the given identifier path relative to this context.

## Declaration

```swift
func descendant(matchingIdentifierPath identifierPath: [String], completion: @escaping @Sendable (CLSContext?, (any Error)?) -> Void)
```

```swift
func descendant(matchingIdentifierPath identifierPath: [String]) async throws -> CLSContext
```

## Parameters

- `identifierPath`: The identifier path of the context to find, relative to the current context.
- `completion`: A closure the method calls with the found context, or nil if none could be found, and an error indicating the reason for failure, if any.

## Mentioned in

Recording student progress Building missing contexts Declaring your app’s context hierarchy

## Discussion

Discussion important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func descendant(matchingIdentifierPath identifierPath: [String]) async throws -> CLSContext For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously. important: ClassKit calls your completion handler on an arbitrary thread. If you need to do work on a particular thread from inside the handler, dispatch that work to the appropriate queue.

## See Also

### Managing context hierarchy

- [identifierPath](classkit/clscontext/identifierpath.md)
- [parent](classkit/clscontext/parent.md)
- [removeFromParent()](classkit/clscontext/removefromparent().md)
- [addChildContext(_:)](classkit/clscontext/addchildcontext(_:).md)
