Why is viewDidUnload not called when a view is deallocated?


Hi there,

I understand that viewDidUnload is called when a view is unloaded by a low memory event, but when I leave the ItemDetail view to return to the ItemsView I believe that the ItemDetailView is destroyed each time and then recreated when another item is selected from the ItemsView. This believe is supported by the fact that dealloc for ItemsDetailView is called after each return from that view.

Now wouldn’t it make sense though that viewDidUnload is called before dealloc, because I am making the assumption here that the view is actually unloaded before you return to the parent view (because it is no longer visible).

Does anybody know why viewDidUnload is not called when views are unloaded and deallocated as part of leaving the view?


Because it would serve no purpose. If we were standing next to a trash can I wouldn’t give you my trash to throw it away, I’d just throw it away. On the other hand, if I didn’t want to throw whatever away, but I did want to set it aside, I’d give whatever to you until I needed it again.