<!--
{
  "availability" : [
    "macOS: 10.10.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSViewController/transition(from:to:options:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSViewController(im)transitionFromViewController:toViewController:options:completionHandler:"
  },
  "title" : "transition(from:to:options:completionHandler:)"
}
-->

# transition(from:to:options:completionHandler:)

Performs a transition between two sibling child view controllers of the view controller.

```
func transition(from fromViewController: NSViewController, to toViewController: NSViewController, options: NSViewController.TransitionOptions = [], completionHandler completion: (@Sendable () -> Void)? = nil)
```

## Parameters

`fromViewController`

A child view controller whose view is visible in the view controller’s view hierarchy.
  
  > Note:
  > The view of this view controller must have a superview, or else this method raises an exception.

`toViewController`

A child view controller whose view is not in the view controller’s view hierarchy.

`options`

A bitmask of options that specify how you want to perform the transition animation. For the options, see the [`NSViewController.TransitionOptions`](/documentation/AppKit/NSViewController/TransitionOptions) enumeration.

`completion`

A block called immediately after the transition animation completes.

## Discussion

Use this method to transition between sibling child view controllers owned by a parent view controller (which is the receiver of this method).

This method adds the view in the `toViewController` view controller to the superview of the view in the `fromViewController` view controller. Likewise, this method removes the `fromViewController` view from the parent view controller’s view hierarchy at the appropriate time. It is important to allow this method to add and remove these views.

> Note:
> The receiver of this method must be the parent view controller of the `fromViewController` and `toViewController` view controllers, or else this method raises an exception.

To create a parent/child relationship between view controllers, use the [`addChild(_:)`](/documentation/AppKit/NSViewController/addChild(_:)) method or the [`insertChild(_:at:)`](/documentation/AppKit/NSViewController/insertChild(_:at:)) method.

---

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)