Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

viewDidUnload versus viewDidDisappear

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 NSNotification when the view controller is removed from the view hierarchy. Between these two methods, does it matter where I post that notification from?

https://developer.apple.com/documentation/uikit/uiviewcontroller

like image 417
kevlar Avatar asked May 14 '12 04:05

kevlar


1 Answers

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.

like image 133
Abhishek Singh Avatar answered Oct 20 '22 01:10

Abhishek Singh