title: iOS App keeps running forever in the background
body: <p>I'm trying to better understand the behavior of Apps in the background in iOS. I have a button with the following action:</p>
  
  <blockquote>
  <pre><code>- (IBAction)createTask:(id)sender {
  
  
      for(int i = 0; i &lt; 10000; ++i){
          NSURL *url = [NSURL URLWithString:@"http://agronigeria.com.ng/wp-content/uploads/2013/06/cocoa.jpg"];
          NSData *data = [NSData dataWithContentsOfURL:url];
          NSLog(@"Image number %d with size %lu", i, (unsigned long)[data length]);
          NSLog(@"Time before task is killed: %f", [[UIApplication sharedApplication] backgroundTimeRemaining]);
      } 
  </code></pre>
    
    <p>}</p>
  </blockquote>
  
  <p>As soon as I tap the button, I press the home button, sending the App to the background. I was expecting this to stop shortly (what's the maximum time an app, without special background modes, can run in the background, BTW?). Instead, it just goes forever. After 10 minutes I stopped it. It goes on even when <code>backgroundTimeRemaining</code> returns 0.</p>
  
  <p>What's going on???</p>
  
  <p>PS I'm running this on a 4S with iOS 7 installed.</p>