• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Using NSProgress with NSURLSessionDownloadTask
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using NSProgress with NSURLSessionDownloadTask


  • Subject: Re: Using NSProgress with NSURLSessionDownloadTask
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 09 Apr 2015 08:39:26 -0700


On Apr 9, 2015, at 12:37 AM, Daryle Walker <email@hidden> wrote:

NSProgress, one of those APIs too new to be well used. Does anyone know how to use it with a downloading task?

Hey! I just started using NSProgress too, yesterday.

One problem is that it’s a secret which API groups support NSProgress.

…and I just ran into this too. The really annoying part is when you make an NSProgress current because you want to add a child, but while it’s current you call a system API that itself uses NSProgress, so you end up adding multiple children to your top-level object, which completely screws up the fractionComplete calculation.

But I don’t know if NSFileManager supports NSProgress, nor where to insert manual calls if it doesn’t.

Apparently it does; it’s the API that I alluded to above. At least, the -createFileAtPath: method uses NSProgress.

NSFileManager isn’t the best API for writing a downloaded file, though. If you’re downloading incrementally, use NSFileHandle or something like it (or just plain old fopen / fwrite / fclose.)

You’d put the NSProgress calls in the NSURLSession delegate methods. Every time you receive a chunk of data, first write it to the file, then add the length of the chunk to the progress’s completedUnitCount.

—Jens
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Using NSProgress with NSURLSessionDownloadTask (From: Daryle Walker <email@hidden>)

  • Prev by Date: Using NSProgress with NSURLSessionDownloadTask
  • Next by Date: Best practices for GCD-based socket I/O with SSL support?
  • Previous by thread: Using NSProgress with NSURLSessionDownloadTask
  • Next by thread: Best practices for GCD-based socket I/O with SSL support?
  • Index(es):
    • Date
    • Thread