Im trying to dismiss a popover from within its content view, and i know that unwind segues is the right way to do this, and it works perfectly well when i create unwind action with storyboard by connecting button to exit icon.
But im stuck with performing same action programatically.
This is my storyboard hierarchy:
[Navigation Controller]
v
[Main View Controller]
v
(popover segue)
v
["B" Tab Bar Controller]
v
[Navigation Controller]
v
["C" View Controller]
So. I have a table view in my "C" View Controller and by tapping on its cell - i want to do some code and then unwind all that stuff all the way to the first Main View Controller.
Easy but not correct way to do this is to send notification to Main View Controller and dismiss popover controller there. Or through delegate or something like that.
But i want to understand how to use "popTo" methods in this situation.
Simple
[self.navigationController popToViewController:[AppModel sharedInstance].mainViewController animated:YES];
just crashes the application with error "Tried to pop to a view controller that doesn't exist."
and im confused about this