<!--
{
  "availability" : [
    "macOS: 10.8.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSPageControllerDelegate/pageController(_:viewControllerForIdentifier:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSPageControllerDelegate(im)pageController:viewControllerForIdentifier:"
  },
  "title" : "pageController(_:viewControllerForIdentifier:)"
}
-->

# pageController(_:viewControllerForIdentifier:)

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

```
@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

Returns the view controller for the specified identifier.

## 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`](/documentation/AppKit/NSPageController/selectedViewController) after a transition if necessary.

---

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)