Consider:
[self.navigationController popToViewController:[[self.navigationController viewControllers]objectAtIndex:1] animated:YES];
Is there a better way to get index of the view controller to pop to? This way if I do something to the nav stack, I don’t have to go back and edit this. I was thinking of maybe storing it in a ivar on the VC or using #define macros. Any ideas?
Edit:
The stack has four view controllers. I used this code to pop from the fourth to the second.
You can replace code in the question with a simple category on
UINavigationControllerwhich can be used wherever it’s appropriate.