Usi Usi
Usi Usi

Reputation: 2997

Error when I exit from a UIWebVIew respond to selector

I use a UIWebView to connect my app to the gmail web view... if I close the the viewController.. after a short time I get this error :

[MailViewController respondsToSelector:]: message sent to deallocated instance 0x142c8c00

I also try to use the method:

- (IBAction)close:(id)sender{

    [web stopLoading];
    [self dismissModalViewControllerAnimated:YES];
}

without any success... how can I fix my problem?

Upvotes: 0

Views: 139

Answers (1)

AliSoftware
AliSoftware

Reputation: 32681

You probably forgot to set the UIWebView's delegate to nil in the dealloc method of your MainViewController.

Thus the webview send some message to its delegate (the MainViewController) after it has been deallocated, explaining the crash.


From the -[UIWebView delegate] method documentation:

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.

Upvotes: 2

Related Questions