Need to Release UIWebView Delegate?
I have a UIWebView named wView. I want to use webViewDidFinishLoad:
in my class, so I am setting the class as the delegate for wView by using this line:
wView.delegate = self;
Everything loads properly, but when I close the UIWebView, the App crashes. If I comment out the wView.delegate = self
, it works and does not crash, but then I can't use webViewDidFinishL开发者_运维技巧oad:
- any ideas? Do I need to release something?
The UIWebView Reference says:
Important: Before releasing an instance of UIWebView for which you have set a delegate, you must first set its delegate property to nil. This can be done, for example, in your dealloc method.
Ensure to set the delegate to nil (wView.delegate = nil). This will prevent webview from trying to access and call methods on a dealloc'd view controller, which would result in a crash.
精彩评论