Reputation: 10891
When I use navigationController?.popViewController(animated: true)
or when I dismiss a UINavigationController
, the deinit
method of my ViewController
s does not get called. Does this mean they are not being deallocated in memory?
How can I deallocate a UINavigationController
and all of its ViewController
s?
Upvotes: 2
Views: 1604
Reputation: 106
As mentioned above, you may have a variable somewhere that's holding a reference to the view controller. If that's the case, that variable is causing Swift to hold onto your View Controller in memory. You can do a few things to fix that:
weak var
, which means that if its the last variable left holding a reference to something, it will be deallocated.Sweepers comment will hopefully help you find the variable in question.
Upvotes: 2