Using iOS I Have 15 ViewControllers now I want to pop from one ViewController to another View Controller.
I am using this code:
SecondViewController *Sec
You can't pop to a new view controller (like you do with your secondViewController example).
When using a UINavigationController you
Add Controller to the stack with:
[self.navigationController pushViewController:<yournewViewController> animated:YES];
Pop to the previous one with :
[self.navigationController popViewControllerAnimated:YES];
Pop to a previous controller in the stack (Must have been pushed before) :
[self.navigationController popToViewController:<ViewControllerToPopTo> animated:YES];
Go back to the root Controller with
[self.navigationController popToRootViewControllerAnimated:YES];
For Swift 3.0, use filter:
let desiredViewController = self.navigationController!.viewControllers.filter { $0 is YourViewController }.first!
self.navigationController!.popToViewController(desiredViewController, animated: true)