I am using a UINavigationController
within my application. And I am trying my best to manage memory allocation. All my views do have a deinit
method which are called/printed whenever an unWindSegue
or navigationController.popViewController()
is performed, given if there are no strong references.
When using performSegueWithIdentifer
and override func prepare(for segue: UIStoryboardSegue, sender: Any?)
the deinit
method is NEVER called/used. I think this is due to the view I am transitioning to is not in memory.
Is it possible to have a conditional statement when performing a segue? As soon as my application is loaded, the HomeView
is in memory. And I can also unwind to it which allows for the current view to be deallocated.
I have several views, and I wish to manage the memory as best as I can. Is is possible to peformSegueWithIdentifier
once and always unwind to a view, once it is in memory, by using a conditional statement?
Pseudo code:
if navigationController.hasViewInMemory() {
peformUnWindSegue()
} else {
peformSegueWithIdentifier()
}
Or is there another way to go about it, which would allow for memory to be deallocated when performing a segue, regardless if the view is in memory or not? My application is based on time and most up to date information, and the last thing I wish is to return old/redundant data.
I am fairly new to memory management so apologises if this question seems a bit idiotic.