ViewDidUnload versus viewDidDisappear

I do not understand when I have to implement something in viewDidUnload compared to viewDidDisappear . What is the difference between the two?

For example, I would like to send NSNotificaton when the view controller is removed from the view hierarchy. Between the two methods, does it matter where I am sending this notification from?

http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIViewController_Class/Reference/Reference.html

+6
source share
2 answers

This is with reference to the documentation for the apple: -

viewDidUnload: -

When a low memory condition occurs and the views of the current dispatcher view are not needed, the system can choose to remove these views from memory. This method is called after the view manager view has been released, and this is your chance to perform a final cleanup. If your view controller stores separate links to the view or its subclauses, you should use this method to release these links. You can also use this method to remove references to any objects created to support the view, but which are no longer needed now when the view is missing.

viewDidDisappear: -

Informs the view manager that its view has been removed from the view hierarchy, which opens at any time, or moves to another view.

+5
source

viewDidDisappear is called every time the view disappears or you switch to another view and viewDidUnload is viewDidUnload when the view of the controllers is freed from memory. (Deprecated in iOS 6.0. Views are no longer cleared in low memory conditions and therefore this method is never called.) See Link .

0
source

Source: https://habr.com/ru/post/915629/


All Articles