title: Using NSProgress to find download speed and time remaining
body: <p>According to the <a href="https://developer.apple.com/library/ios/documentation/Foundation/Reference/NSProgress_Class/Reference/Reference.html#//apple_ref/occ/instp/NSProgress/localizedAdditionalDescription">documentation for <code>NSProgress</code></a> I see that <code>-[NSProgress localizedAdditionalDescription]</code> can report download speed and time remaining, e.g.:</p>
  
  <blockquote>
    <p>1.61 GB of 3.22 GB (2 KB/sec) — 2 minutes remaining</p>
  </blockquote>
  
  <p>However, I'm not able to get those details when I associate an <code>NSProgress</code> to a <code>NSURLSessionDownloadTask</code>. Here's my code:</p>
  
  <p><strong>Downloader.h</strong></p>
  
  <pre><code>@interface Downloader : NSObject
  @property NSProgress *overallProgress;
  -(void)startDownload;
  @end
  </code></pre>
  
  <p><strong>Downloader.m</strong></p>
  
  <pre><code>- (void)startDownload {
  
      self.overallProgress = [NSProgress progressWithTotalUnitCount:100];
  
      [self.overallProgress setKind:NSProgressKindFile];
      [self.overallProgress setUserInfoObject:NSProgressFileOperationKindKey forKey:NSProgressFileOperationKindDownloading];
  
  
      [self.overallProgress becomeCurrentWithPendingUnitCount:100];
      [self work1];
      [self.overallProgress resignCurrent];
  }
  
  - (void)work1 {
  
      NSProgress *firstTaskProgress = [NSProgress progressWithTotalUnitCount:1];
      [firstTaskProgress setKind:NSProgressKindFile];
      [firstTaskProgress setUserInfoObject:NSProgressFileOperationKindKey forKey:NSProgressFileOperationKindDownloading];
  
      NSURL *downloadURL = [NSURL URLWithString:@"http://ipv4.download.thinkbroadband.com/200MB.zip"];
      NSURL *destinationDirectory = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] firstObject];
      NSURL *destinationURL = [destinationDirectory URLByAppendingPathComponent:[downloadURL lastPathComponent]];
  
      NSURLSession *session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
      NSURLSessionDownloadTask *fileDownloadTask =
      [session downloadTaskWithURL:downloadURL
                 completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error){
  
                     [[NSFileManager defaultManager] removeItemAtURL:destinationURL error:NULL];
  
                     [[NSFileManager defaultManager] moveItemAtURL:location toURL:destinationURL error:nil];
  
                     [firstTaskProgress setCompletedUnitCount:1];
                 }];
  
      [fileDownloadTask resume];
  }
  </code></pre>
  
  <p><strong>DownloadObserver.m</strong></p>
  
  <pre><code>-(void)viewDidAppear:(BOOL)animated{
      [super viewDidAppear:animated];
  
      downloader = [Downloader new];
  
      [downloader addObserver:self
                   forKeyPath:@"overallProgress.fractionCompleted"
                      options:NSKeyValueObservingOptionNew
                      context:NULL];
  
      [downloader startDownload];
  
  }
  
  -(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
  {
      NSLog(@"%@", [downloader.overallProgress localizedAdditionalDescription]);
  }
  </code></pre>
  
  <p>This only prints out:</p>
  
  <blockquote>
    <p>0 of 100</p>
    
    <p>Zero KB of 100 bytes</p>
  </blockquote>
  
  <p>How can I get <code>localizedAdditionalDescription</code> to print the download speed and time remaining? </p>