title: iOS, stop running a function when "back" button is pressed
body: <p>The application is made of navigation views.
  I am calling a function in viewDidAppear which is </p>
  
  <pre><code>[self extractInfoWithWebsite:[NSString stringWithFormat:@"http://www.cineklik.com/%@-%@.aspx", self.cinemaType, self.location]];
  </code></pre>
  
  <p>This function does HTML parse from the a current webpage on the internet.
  The code is kind of long to share but the idea is that it extract data from a website.</p>
  
  <p>The problem is that I am having is that if the user decides to click the back button of the navigation before that the information is loaded, the page stays the same and the application stops functionning (not a crash but becomes static, doesn't do anyth anymore).</p>
  
  <p>Is there a solution to this?
  Thank you in advance</p>
  
  <p>EDIT:</p>
  
  <p>I changed the code to the following:
              NSOperationQueue *queue = [NSOperationQueue new];</p>
  
  <pre><code>    /* Create our NSInvocationOperation to call loadDataWithOperation, passing in nil */
      NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self
                                                                              selector:@selector(extractInfoWithWebsite:)
                                                                                object:[NSString stringWithFormat:@"http://www.cineklik.com/%@-%@.aspx", self.cinemaType, self.location]];
  
      /* Add the operation to the queue */
      [queue addOperation:operation];
      [operation release];
  </code></pre>
  
  <p>Now I am able to press the back button without freezing, but now there is a crash with the following error:
  Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
  I think it s because my function was still running in the background.
  How to solve this issue?</p>