---
title: "pageController(_:viewControllerForIdentifier:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nspagecontrollerdelegate/pagecontroller(_:viewcontrollerforidentifier:)"
---

# pageController(_:viewControllerForIdentifier:)

Returns a view controller the page controller uses for managing the specified identifier.

## Declaration

```swift
@MainActor optional func pageController(_ pageController: NSPageController, viewControllerForIdentifier identifier: NSPageController.ObjectIdentifier) -> NSViewController
```

## Parameters

- `pageController`: The page controller.
- `identifier`: The identifier for a view controller.

## Return Value

Return Value Returns the view controller for the specified identifier.

## Discussion

Discussion Your implementation of this method should return the requested view controller for the identifier or create and return a new view controller. NSPageController will cache as many view controllers and views as necessary to maintain performance. This method is called whenever another instance is required. The view controller may become the selectedViewController after a transition if necessary.

## See Also

### Managing View Controllers

- [pageController(_:identifierFor:)](appkit/nspagecontrollerdelegate/pagecontroller(_:identifierfor:).md)
- [pageController(_:prepare:with:)](appkit/nspagecontrollerdelegate/pagecontroller(_:prepare:with:).md)
- [pageController(_:frameFor:)](appkit/nspagecontrollerdelegate/pagecontroller(_:framefor:).md)
- [NSPageController.ObjectIdentifier](appkit/nspagecontroller/objectidentifier.md)
