iOS UINavigationController - removing a view controller from the navigation stack does release it at all
<p>I have been fiddling with UINavigationController for while but this problem is a little tricky for me now,</p>

<p>I have a UINavigationController with three view controllers.</p>

<p><strong>A -> B -> C</strong></p>

<p>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.</p>

<p>Removal code:</p>

<pre><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))!)
            }
        }
    }
</code></pre>

<p>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.</p>

<p>FYI I don't want to set a custom back button and override the action, I want the default behavior and with no leaks.</p>

<p>Any help is appreciated.</p>