---
title: "transition(from:to:options:completionHandler:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsviewcontroller/transition(from:to:options:completionhandler:)"
---

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

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

## Declaration

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

```swift
func transition(from fromViewController: NSViewController, to toViewController: NSViewController, options: NSViewController.TransitionOptions = []) async
```

## 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 doc://com.apple.appkit/documentation/AppKit/NSViewController/TransitionOptions enumeration.
- `completion`: A block called immediately after the transition animation completes.

## Discussion

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(_:) method or the insertChild(_:at:) method.

## See Also

### Managing Child View Controllers in a Custom Container

- [addChild(_:)](appkit/nsviewcontroller/addchild(_:).md)
- [children](appkit/nsviewcontroller/children.md)
- [insertChild(_:at:)](appkit/nsviewcontroller/insertchild(_:at:).md)
- [removeChild(at:)](appkit/nsviewcontroller/removechild(at:).md)
- [removeFromParent()](appkit/nsviewcontroller/removefromparent().md)
- [preferredContentSizeDidChange(for:)](appkit/nsviewcontroller/preferredcontentsizedidchange(for:).md)
