I am fairly new to the whole concept of memory management and ARC.
I've recently looked into it and found mixed success.
Firstly it should be noted that some ViewController
do deinitialize but I am still learning and cleaning up my application.
However, a common pattern I have noticed is that when I use the line navigationController?.popViewController(animated: true)
this does infact deinit
a view controller, given if there are no strong references.
However, my issue is that when I use a segue and use performSegue(withIdentifier: "showDetail_Segue", sender: nil)
the deinit
method is never used/called. (I just have a print statement to indicate whether a view has been deinitalized). In most cases, when I perform a segue, I am passing data to another view controller and as a result, I use the following function override func prepare(for segue: UIStoryboardSegue, sender: Any?) {}
.
I have tried to change my segue to navigationController?.pushViewController(VC, animated: true)
but my application crashes.
Am I missing something here?
The ViewControllers
that deinitliaze when the navigationController
is popped
also do not deinitialze when performing a segue
programmatically.
Could someone please tell me what I'm doing wrong?
Thank you.