Trying to hunt down the cause of crashing on certain devices. I am noticing that my view controllers are receiving didReceiveMemoryWarning
, but NOT viewDidUnload
. And according to Apple:
you would not use didReceiveMemoryWarning to release references to view objects, you might use it to release any view-related data structures that you did not already release in your viewDidUnload method. (The view objects themselves should always be released in the viewDidUnload method.)
So,
A: Why is viewDidUnload
not called? I can't remove my view objects here if it is never called.
B: If I'm not supposed to remove my view objects in didReceiveMemoryWarning
, where else would I do this?
C: Using ARC, should I still need to remove view objects, set arrays to nil, etc?
As the other mentioned
viewDidUnload:
is deprecated in iOS 6. But as additional information you should know, that it is seldom necessary to unload aUIView
since iOS 6 is doing its magic thingie in the background -it is destroying the bitmap layer of the backingCALayer
of the view (which is by far the biggest "part" of aUIView
). If the view is needed again iOS will calldrawRect:
where you compose your view and everything will be ok.For more information read this great article of Joe Conway: ViewController lifecycle in iOS 6