Looking at the UIWebView docs, it says that
Before releasing an instance of UIWebView for which you have set a delegate, you must first set the UIWebView delegate property to nil before disposing of the UIWebView instance. This can be done, for example, in the dealloc method where you dispose of the UIWebView
I'm creating a webview on the fly on a UITableView cell tap. I'm not sure how to do the "set delegate to nil" bit, since I don't track the UIWebView after its pushed to the navigation stack. I would have though that the UIWebView's dealloc method would be calling release on the delegate anyway?
Here's what I'm doing:
UIWebView *webView = [[UIWebView alloc] init];
UIViewController *viewController = [[UIViewController alloc] init];
// Start the webview loading, etc
...
// set the delegate
[webView setDelegate:self];
// Add the webview to the viewcontroller
[viewController setView:webView];
[[self navigationController] pushViewController:viewController animated:YES];
[webView release];
[viewController release];
I get the impression that I should write
[webView release];
[viewController release];
[self release]; // Releasing the delegate as per the docs.
But that seems kind of awkward, or have I interpreted it correctly?