I have been fiddling with UINavigationController for while but this problem is a little tricky for me now,
I have a UINavigationController with three view controllers.
A -> B -> C
and when I come to C view controller in the viewDidLoad() I am removing B from the stack now if I tap back on C it goes to A, everything is working as expected but B never gets released but C does.
Removal code:
if self.navigationController != nil{
for viewController in (self.navigationController?.viewControllers)!{
if viewController.isKindOfClass(MyVCKind.self){
self.navigationController?.viewControllers.removeAtIndex((self.navigationController?.viewControllers.indexOf(viewController))!)
}
}
}
So I tested and profiled B view controller just to be sure that I don't have anything leaking there, everything is fine when I go from B -> A by tapping back on B, B is getting flushed out but the problem is only when I am manually removing B from the stack.
FYI I don't want to set a custom back button and override the action, I want the default behavior and with no leaks.
Any help is appreciated.