I don't understand when I should implement something in viewDidUnload
versus viewDidDisappear
. What's the difference between the two?
For instance, I'd like to send an NSNotificaton
when the view controller is removed from the view hierarchy. Between these two methods, does it matter where I post that notification from?
This is with reference to apple's documentation:-
viewDidUnload:-
When a low-memory condition occurs and the current view controller’s views are not needed, the system may opt to remove those views from memory. This method is called after the view controller’s view has been released and is your chance to perform any final cleanup. If your view controller stores separate references to the view or its subviews, you should use this method to release those references. You can also use this method to remove references to any objects that you created to support the view but that are no longer needed now that the view is gone.
viewDidDisappear:-
Notifies the view controller that its view was removed from a view hierarchy that is everytime view dissapears or move to other view.
viewDidDisappear
is called every time when the view is disappears or you go to other view andviewDidUnload
is called when the controller’s view is released from memory. (Deprecated in iOS 6.0. Views are no longer purged under low-memory conditions and so this method is never called.) see the reference.