What is the correct way to clear a UIWebView delegate ?
In my dealloc function, I added
[myWebView setDelegate:nil];
[myWebView release];
And is the first ligne necessary ?
EDIT : and what if my object was not a UIWebView but a NSFetchedResultsController ?
Thanks
Setting the delegate to nil is one thing. Other, quite as important or even more, is how to cleanly shut down a loading UIWebView in a case when you don’t care about the result anymore and you’re about to release a view containing your UIWebView.
Here is a really good answer to above questions and more: How to safely shut down a loading UIWebView in viewWillDisappear?. It’ll give a good overview on UIWebView’s life-cycle.
A hint on calling
stopLoading: you don’t have to check if anything is being loaded withisLoadingbefore callingstopLoading– just callstopLoadingdirectly and it will do nothing if nothing is being loaded.