title: Retrying a failed download in URLSession:task:didCompleteWithError
body: <p>How do I resume the download task after a delay?</p>
  
  <p>I had a look at this thread:</p>
  
  <p><a href="https://stackoverflow.com/questions/31209372/ios-nsurlsession-how-to-retry-in-didcompletewitherror">iOS NSURLSession, how to retry in didCompleteWithError</a></p>
  
  <p>The third approach suggested by Rob is what I'm trying to do, but I don't know how to set a delay.</p>
  
  <p>So far, I've got something like this:</p>
  
  <pre><code>-(void)URLSession:(NSURLSession*)session task:(NSURLSessionTask*)task didCompleteWithError:(NSError*)error {
    if ( error == nil )
      return;
  
    NSData* resume_data = error.userInfo[NSURLSessionDownloadTaskResumeData];
    NSURLSessionDownloadTask* new_task = [_session downloadTaskWithResumeData:resume_data];  
    [new_task resume];
  }
  </code></pre>
  
  <p>I'd like to wait 10 seconds (say) and then resume.</p>