Muneeb Rehman
Muneeb Rehman

Reputation: 129

Unable to get the concept of popping navigation control in current class

self.navigationController!.popViewControllerAnimated(true)

So in above line i am having confusion that why I am getting navigation controller instance in the current class. According to the storyboard, navigation controller is present outside this class, but how come are we accessing the navigation controller in the current class?

Upvotes: 0

Views: 35

Answers (1)

Simon McLoughlin
Simon McLoughlin

Reputation: 8465

The current viewController is being managed by the navigationController.

You could think of it in a similar way to a parent / child relationship. The navigationController is somewhat functioning like the parent of the viewController.

That property provides a reference to the navigationController provided it exists. In the same way you can say view.superView to access the parent view that the current view is inside.

Upvotes: 1

Related Questions