This is more of a discussion on an issue and my implementation, which seems to be causing issues.
My app has a tab bar and navigation controllers. Within each tab you can go into views, and the tab bar will be hidden until you click back from your sub view.
I have a navigation controller for each on my tabs, these are declared as outlets in my app delegate and also have @class tab1navcontroller
A typical use would be.
MyAppDelegate *delegate = (MyAppDelegate *)[[UIApplication sharedApplication]
delegate];
[delegate.tab1NavController pushViewController:nextController animated:YES];
I haven’t had many problems with this in the past and I believe I copied the approach from a book I was reading at the time.
However, I had a discussion with a colleuge some months ago who said I should only have one navigation controller for my app.
At the time I did try and replace the code (shown above) and use self.navigationcontroller instead, but this caused problems, I can’t remember what they were, but I discarded those fixes.
Today an error has occurred, when the view is pushed and back tapped quickly.
I also ran the app with the zombie profiler and this indicated the code above was the problem.
I believe the code above could be causing leaks.
I just don’t know what approach is best and where to go from here ?
As @Dima said in the comment, your colleague was wrong. In my app I have one tabbarController as the window rootViewController. You can either expose it in a property or its viewController array or the individual navigation controllers. You CANNOT reuse a navigation controller in multiple tabs – its one for each, or a mix. That is, in my tabbarController, I have 4 naviationControllers and one plain UIViewController subclass.
The tab bar controller retains the all its viewControllers, and the navigationControllers retain all their viewControllers. That said, you get into problems if you have a ‘assign’ type reference to a viewController that gets popped.