I have 5 view controllers(say A,B,C,D,E) in my navigation stack. ViewController E is in the top of the stack. On a button click in ViewController E, I want to move to ViewController C. For that I am using the following code.
NSMutableArray *navigationarray = [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
[navigationarray removeObjectAtIndex:4];
[navigationarray removeObjectAtIndex:3];
self.navigationController.viewControllers = navigationarray;
[navigationarray release];
Is there a better way to do this, where I can check which viewController is being removed from the navigation array
Edit: In this case, could I check whether the viewcontroller being removed isKindOfClass
of the class of the particular view controller like
if ([[navigationarray objectAtIndex:4] isKindOfClass:[MyClass class]])