Are there any scenarios in which dealloc will be called without viewWillDisappear, not called?

In the controller, we added the observer to viewDidAppearand deleted it in viewWillDisappear. There is init/viewDidLoadno observer.

In this case, the bottom line for security purposes / is required in the method dealloc?

[[NSNotificationCenter defaultCenter] removeObserver:self];

Now the question arises / are there any scenarios in which it deallocwill be called without viewWillDisappearwhich will not be called? How about when memory alerts are triggered. What happens in these cases?

Thank.

+4
source share
1 answer

One of the scenarios:

  • VC1implements a class HelperVC, it delegates and adds HelperVCas you view it.
  • HelperVC closeAll , VC1.
  • closeAll VC1 HelperVC nil.
  • dealloc HelperVC viewWillDisappear. HelperVC, HelperVC nil.
+4

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


All Articles