Search code examples
iphoneobjective-ciosxcodeinstruments

EXC_BAD_ACCESS and Zombies, Yet not really sure why it keeps coming up


I don't know what's going wrong here. The crash happens when switching back and forth between views.

Here's what instruments gives me: Crash in instruments

Clicking into it references this code with the first action :

-(IBAction)pushnews; {
NewsViewController *news = [[[NewsViewController alloc]init]autorelease];
news.title =@"Page";
[self.navigationController pushViewController:news animated:YES]; }

I use autorelease sometimes but usually I just release it my self. Should I get rid of autorelease and add [news retain]

What am I doing wrong?


Edit based on answers: Following EmptyStack's Advice: ViewWillDisappear Code looks like this:

- (void)viewWillDisappear:(BOOL)animated {
webView.delegate = nil; } 

This seems to resolve issues (pending more testing)

In viewdidload I said: webView.delegate = self;, which may have been the issue!


Solution

  • My guess is that, there is a UIWebView in NewsViewController, and it is causing the crash. It is possible that, a delegate method of web view is called after the web view is released. If so, try to setwebView.delegate = nil; in NewsViewController's viewWillDisappear: method.