---
title: "addChild(_:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uiviewcontroller/addchild(_:)"
---

# addChild(_:)

Adds the specified view controller as a child of the current view controller.

## Declaration

```swift
func addChild(_ childController: UIViewController)
```

## Parameters

- `childController`: The view controller to be added as a child.

## Mentioned in

Creating a custom container view controller

## Discussion

Discussion This method creates a parent-child relationship between the current view controller and the object in the childController parameter. This relationship is necessary when embedding the child view controller’s view into the current view controller’s content. If the new child view controller is already the child of a container view controller, it is removed from that container before being added. This method is only intended to be called by an implementation of a custom container view controller. If you override this method, you must call super in your implementation.

## See Also

### Managing child view controllers in a custom container

- [children](uikit/uiviewcontroller/children.md)
- [removeFromParent()](uikit/uiviewcontroller/removefromparent().md)
- [transition(from:to:duration:options:animations:completion:)](uikit/uiviewcontroller/transition(from:to:duration:options:animations:completion:).md)
- [shouldAutomaticallyForwardAppearanceMethods](uikit/uiviewcontroller/shouldautomaticallyforwardappearancemethods.md)
- [beginAppearanceTransition(_:animated:)](uikit/uiviewcontroller/beginappearancetransition(_:animated:).md)
- [endAppearanceTransition()](uikit/uiviewcontroller/endappearancetransition().md)
- [hierarchyInconsistencyException](uikit/uiviewcontroller/hierarchyinconsistencyexception.md)
