I have an app with a TabBarNavigationController and a NavigationController. The views of the navigation Controller are"
HomeViewControllerCharacterViewControllerFinalViewController
I have a function in CharacterViewController and FinalViewController so that if the user tap the tab bar item of the navigation controller it shows the HomeViewController:
func tabBarController(tabBarController: UITabBarController, didSelectViewController viewController: UIViewController) {
if tabBarController.selectedIndex == 0{
self.navigationController?.popToRootViewControllerAnimated(false)
}
}
When the user is in CharacterViewController or in FinalViewController and goes to the other tab then taps again the Navigation Controller tab the popToRootViewControllerAnimated gets called and the user is in HomeViewController.
Everything until this point works, the problem is when at this point I tap the other tab from the tab bar, the app crashes. In the logs it shows me:
2015-09-06 14:02:24.120 PIBA[32338:510545] *** -[PIBA.CharacterViewController respondsToSelector:]: message sent to deallocated instance 0x79e88320
If I use a breakpoint it shows:
0x8a217f <+783>: jmp 0x8a2288
(Which doesn't helps me)
So I searched for NS Zombies and the test showed that in the line:
self.navigationController?.popToRootViewControllerAnimated(false)
An object is being released
But what object? and how can I retain it?