Whats the proper way to release a UIWebView?

巧了我就是萌 提交于 2019-12-11 06:12:54

问题


I've been looking at many code samples on the internet. If I add an UIWebView from interface builder as an IBOutlet. Is it right that in the dealloc method of the controller, I need to do the following?

[webView stopLoading];
webView.delegate = nil;
[webView release];

and what about in the viewDidUnload method?


回答1:


In the UIViewController class reference, Apple recommends that for iOS 3.0 and above, you release references to objects that cannot be easily recreated.

In the same document Apple also recommends that you release these references in dealloc.

The relevant method documentation is in the viewDidUnload section of the class reference; it lays this all out in detail and covers both viewDidUnload and dealloc.




回答2:


That is an appropriate way to handle that.



来源:https://stackoverflow.com/questions/3697349/whats-the-proper-way-to-release-a-uiwebview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!