Search code examples
iosobjective-cuinavigationcontrollerdealloc

Do the View Controllers Popped Out of the Navigation Stack Dealloc?


Might be a stupid question, and it seems they indeed do, but I just wanted to make sure if this always is the case, or if you can design it in a way that they don't dealloc. Looks like every time a view controller is pushed on to the stack, a new instance of that view controller is created; Is this the default behaviour?


Solution

  • If you are using a storyboard, then yes, every time a view controller is pushed a new instance is created and added to the navigation controller stack.

    When the view controller is popped if nobody is holding a strong reference to it (which is the default), then it is deallocated.