---
title: "viewController(forKey:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uiviewcontrollercontexttransitioning/viewcontroller(forkey:)"
---

# viewController(forKey:)

Returns a view controller involved in the transition.

## Declaration

```swift
func viewController(forKey key: UITransitionContextViewControllerKey) -> UIViewController?
```

## Parameters

- `key`: The key identifying the view controller you want. For a list of possible keys, see View Controller Transition Keys.

## Return Value

Return Value The view controller object for the specified key or nil if the view controller could not be found.

## See Also

### Accessing the transition objects

- [containerView](uikit/uiviewcontrollercontexttransitioning/containerview.md)
- [view(forKey:)](uikit/uiviewcontrollercontexttransitioning/view(forkey:).md)
