I have a tabbar controller app with two tabs. One of my tabs uses a navigation controller.
The navigation controller that I made for this resides in View A. View A acts solely as a controller and automatically pushes View B which in turn pushes view C which pushes View D.
I want the next view to be View B, so I used
NSArray *viewControllers = [[self navigationController] viewControllers];
int i=0;
while (! [[[viewControllers objectAtIndex:i] nibName]
isEqualToString:@"ViewBController"]
&& i < [viewControllers count])
i++;
to get the view I want (in some cases the order of the views may change so I don’t want to hardcode it)
and then
self.navigationController popToViewController:[viewControllers objectAtIndex:i] animated:NO];
to get back to view B
My issue is that the app crashes at this point. Well technically it crashes after it deallocs View C (I put nslogs there to figure that out).
I have no idea what my issue can be? Can anyone provide insight?
EDIT: I also tried making a new view controller, View E, and pushing that and it still crashes
I finally figured out my problem, it turned out not to be a navigation issue.
Before switching views I had an alert that I set to autorelease, and then I also released it.
I figured this out by using NSZombie, which is awesome.
For anyone who needs the reference check this out:
http://cocoadev.com/index.pl?NSZombieEnabled