• 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: File size of a downloadable file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: File size of a downloadable file


  • Subject: Re: File size of a downloadable file
  • From: Jeremy Dronfield <email@hidden>
  • Date: Sun, 18 Apr 2004 10:49:20 +0100

Just as an addition to this, there's a neat demonstration of using these delegate methods to increment a progress indicator in /Developer/Examples/WebKit/Downloader.

Jeremy


On 17 Apr 2004, at 9:36 pm, Scott Anguish wrote:

On Apr 17, 2004, at 2:02 PM, Pat Homelvig wrote:

*This message was transferred with a trial version of CommuniGate(tm) Pro*
Does anyone know how you might be able to programmatically get the size of a file you are going to download before you start downloading?

I would like to show the progress of downloading a file in my app (xxxx bytes of yyyy bytes total).


The NSURLResponse returned by the connection:didReceiveResponse: (or download:) delegate method includes a method -expectedContentLength.

it'll return the length that you can expect (if it's possible to determine) or -1 if you can't.

then in your

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data

{

// append the new data to the receivedData

[receivedData appendData:data];

}
you can increment the current length received data by checking the length of the newly received data chunk and incrementing a counter..
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >File size of a downloadable file (From: Pat Homelvig <email@hidden>)
 >Re: File size of a downloadable file (From: Scott Anguish <email@hidden>)

  • Prev by Date: Re: NSObjectController and NSDefaultsController Binding?
  • Next by Date: Re: Current mouse screen?
  • Previous by thread: Re: File size of a downloadable file
  • Next by thread: NSTextView subclass won't draw
  • Index(es):
    • Date
    • Thread