title: NSURLSessionDownloadTask - read downloaded data before didFinishDownloading
body: <p>I am trying to replace <code>NSURLConnection</code> with <code>NSURLSession</code>, but I found that with <code>NSURLSession</code> I couldn't read the intermediate data chunks like I did in <code>NSURLConnection</code> with the delegate method. </p>
  
  <pre><code>- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
  </code></pre>
  
  <p>I used to start using the data before completion. I am kind of streaming. How I can access the downloaded data before <code>NSURLSession</code> complete? </p>
  
  <p>I notice there is a <code>(NSURL *)location</code> which is temporary saved data location from <code>NSURLSession</code> before completion, but I can I get this URL before completion? </p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p>Tried this as suggested from Rob:</p>
  
  <pre><code>NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
  NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:[NSOperationQueue mainQueue]];
  NSURLSessionTask *task = [session dataTaskWithRequest:request];
  [task resume];
  </code></pre>
  
  <p>However, only didRecieveResponse was called </p>
  
  <pre><code>- (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler
  </code></pre>
  
  <p>but didReceiveData not called. </p>
  
  <p>I tried to change the task to downloadTask</p>
  
  <pre><code>NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
  NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate:self delegateQueue: [NSOperationQueue mainQueue]];
  NSURLSessionDownloadTask * downloadTask =[defaultSession downloadTaskWithRequest:request];
  [downloadTask resume];
  </code></pre>
  
  <p>It works with the download delegate, but data delegate (didReceiveData) not called.</p>
  
  <p>Anybody can tell me what did I get wrong? </p>