title: EXC_BAD_ACCESS in UIWebView
body: <p>I just downloaded the crash reports for one of my iPhone apps from iTunes Connect.  The most common crash has a trace like the following:</p>
  
  <pre><code>Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
  Exception Codes: KERN_INVALID_ADDRESS at 0xa1b1c1db
  Crashed Thread:  0
  
  Thread 0 Crashed:
  0   libobjc.A.dylib                 0x3030e6f4 objc_msgSend + 16
  1   UIKit                           0x30ebebee -[UIWebView webView:resource:didFinishLoadingFromDataSource:]
  2   UIKit                           0x30ebe5ca -[UIWebViewWebViewDelegate webView:resource:didFinishLoadingFromDataSource:]
  3   CoreFoundation                  0x32b73b5c __invoking___ + 60
  4   CoreFoundation                  0x32bc67be -[NSInvocation invoke]
  5   WebCore                         0x320baa86 HandleDelegateSource
  6   CoreFoundation                  0x32bb8a96 CFRunLoopRunSpecific
  7   CoreFoundation                  0x32bb8356 CFRunLoopRunInMode
  8   GraphicsServices                0x30544cd4 GSEventRunModal
  9   GraphicsServices                0x30544d80 GSEventRun
  10  UIKit                           0x30d2c768 -[UIApplication _run]
  11  UIKit                           0x30d2b46c UIApplicationMain
  </code></pre>
  
  <p>I'm about 80% sure this is an issue internal to UIWebView and outside the scope of what I can address.  Does anyone have any suggestions on how to narrow down this issue to help identify whether it's an issue with the OS and UIWebView, or an issue that I can fix and address in my code?  Thanks in advance.</p>
  
  <p>UPDATE: The UIWebView in question is in a view that gets released when the user hits the back button of the corresponding navigation controller.  The accepted solution seems to provide a good explanation for why this error is occurring.</p>
  
  <p>Before suggested solution:</p>
  
  <pre><code>- (void)dealloc {
      [webView release];
  
      [super dealloc];
  }
  </code></pre>
  
  <p>After suggested solution:</p>
  
  <pre><code>- (void)dealloc {
      webView.delegate = nil;
      [webView stopLoading];
      [webView release];
  
      [super dealloc];
  }
  </code></pre>