---
title: "didMove(toParent:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uiviewcontroller/didmove(toparent:)"
---

# didMove(toParent:)

Called after the view controller is added or removed from a container view controller.

## Declaration

```swift
func didMove(toParent parent: UIViewController?)
```

## Parameters

- `parent`: The parent view controller, or nil if there is no parent.

## Mentioned in

Creating a custom container view controller

## Discussion

Discussion Your view controller can override this method when it wants to react to being added to a container. If you are implementing your own container view controller, it must call the didMove(toParent:) method of the child view controller after the transition to the new controller is complete or, if there is no transition, immediately after calling the addChild(_:) method. The removeFromParent() method automatically calls the didMove(toParent:) method of the child view controller after it removes the child.

## See Also

### Responding to containment events

- [willMove(toParent:)](uikit/uiviewcontroller/willmove(toparent:).md)
