---
title: hierarchyInconsistencyException
framework: uikit
role: symbol
role_heading: Type Property
path: uikit/uiviewcontroller/hierarchyinconsistencyexception
---

# hierarchyInconsistencyException

Raised if the view controller hierarchy is inconsistent with the view hierarchy.

## Declaration

```swift
class let hierarchyInconsistencyException: NSExceptionName
```

## Discussion

Discussion When a view controller’s view is added to the view hierarchy, the system walks up the view hierarchy to find the first parent view that has a view controller. That view controller must be the parent of the view controller whose view is being added. Otherwise, this exception is raised. This consistency check is also performed when a view controller is added as a child by calling the addChild(_:) method. It is also allowed for a view controller that has no parent to add its view to the view hierarchy. This is generally not recommended, but is useful in some special cases.

## See Also

### Managing child view controllers in a custom container

- [children](uikit/uiviewcontroller/children.md)
- [addChild(_:)](uikit/uiviewcontroller/addchild(_:).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)
