Home>

I have a question about NavigationController.
I noticed that the navigationController property can be used in the UIViewController class as shown below.
I personally think that the fact that this property appears means that the navigationController property is originally implemented in UIViewController, but why does this property exist even though the view is not set as a navigation controller? Is it?
Please professor.

  • Answer # 1

    DeveloperDocument/UIViewController

    If the view controller or one of its ancestors is a child of the navigation controller, this property contains the navigation controller it owns. This property is nil if the view controller is not embedded within the navigation controller.

    Looking at the above document, I think it is to make it easy to get the NavigationController included in the upper hierarchy from the UIViewController.

    Supplement
    So, I think that the following of the questioner will be as inferred.

    I think that the navigationController property is originally implemented in UIViewController.