As we all know, when developing iOS, using arc, the DEALLOC function does not need to be implemented, but it will go wrong.
But in some special cases, the Dealloc function is still needed.
For example, when the screen is closed, some resources of Viewcontroller need to be released,
In the viewdiddissppear is not necessarily suitable, viewdidunload generally only in memory warning when the call.
Without arc, we would naturally think of the dealloc function.
In fact, in the ARC environment, there is no dealloc function is forbidden, or can be used. Just don't need to call [supper dealloc] anymore.
For example, there is a uiwebview on the screen, its delegate is the viewcontroller of the picture, after the WebView loading is completed, it is necessary to do something, for example, to stop the indicator and so on.
If the screen is closed before webview loading is complete, the Viewcontroller is released after the screen is closed. However, since WebView is loading the page and is not released immediately, after the page is loaded, the callback method in delegate (Viewcontroller) will be faulted because Viewcontroller has been released at this time. (Message sent to deallocated instance)
The solution is to release WebView's delegate in Dealloc.
-(void) Dealloc {
Self.webView.delegate = nil;
}
Use of Dealloc in IOS arc environment