title: Abandoning network requests in iOS apps
body: <p>After I push myViewController onto the navigation stack I make a simple network request for some data that populates a few fields on myViewController. I don't want this request to block the main thread so I make it using <code>performSelectorInBackground</code>. When the request returns I use <code>performSelectorOnMainThread</code> to update the UI.</p>
  
  <p>This approach works fine except for abandoning the request. Say the user pushes the view controller, the network request starts, then the user immediately pops the view controller and does something else in the app. In this case the network request comes back to a non-existent object. <strong>How can I handle this case?</strong></p>
  
  <p>I've considered a more robust networking layer where each request has a delegate the handles the response. Using this architecture I could nil out the delegate when the view controller is popped hence avoiding the problem of the request returning to nothing. I'm not sure if this is the best way to go.</p>