I'm trying to get my head around view lifecycle and the memory management related to it.
I am looking to improve my understanding while also asking for recommendations on the best approach.
Let's say we have a NSTabViewController with 2 childViewControllers.
One of them is a NSViewController with an NSTextView.
Here is how I think of it.
When the view (and the NSTextView as part of the view hierarchy) is removed or hidden (as part of a tab selection), I want to also discard the contents (i.e. string/textStorage) in the NSTextView.
When the view is added or about to become visible, I want to (potentially load) and set the contents in the NSTextView.
Looking at the viewWillAppear/viewWillDisappear methods, the former is is called when "the view is about to be added to the view hierarchy of the view controller" while the latter is also called when "The view is about to be hidden or obscured".
Effectively that means, there is a case (when the view gets hidden) where the viewWillAppear is not paired with the viewWillDisappear. Is that by design?
Since as developers, we are not expected to manage any of the memory related to the view hierarchy, does that also extend to any data related to the view hierarchy?
In other words, are we only supposed to implement viewWillAppear in order to set the data to the view and leave the rest?
If so, are you only supposed to respond to memory warnings when the system itself deems necessary to deal with "excesive" memory usage?