Reputation: 129
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
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