• 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
how should I go about downloading files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how should I go about downloading files


  • Subject: how should I go about downloading files
  • From: "Laimonas Simutis" <email@hidden>
  • Date: Thu, 10 Apr 2008 20:04:46 -0500

Hey,

This is my first cocoa projects so I am kind of finding my way around
the framework. The question I have is maybe more related to the design
practices with cocoa.

I make a HTTP call to a server which gives me back a list of urls
pointing to mp3 files. For each url handling I created FileDownloader
class that inside uses NSURLDownload class to download the mp3 file.
All works fine but I have a problem with finding a solution for
"queuing" the downloads. I want to control how many files will be
downloaded concurrently (usually it will be one or two). However right
now what I have is basically this:

NSArray *arr = ... get this puppy from parsing the server response

int i;
for(i=0; i<[arr count]; i++)
{
	NSString *url = [arr objectAtIndex:i];

	// now fetch the file
	FileDownloader *downloader = [[FileDownloader alloc] init];
	[downloader setDelegate:self];
	[downloader downloadItem:url];
}

The problem with the above is that I spawn as many downloaders as the
urls returned by the server since downloadItem does't block. What
would be the best way to go about queueing these guys up? That way I
can have a predetermined set of progress indicators and stuff like
that.

Let me know if the question is too broad and i will try to narrow it down.

I find this delegate stuff in cocoa all over the places and it is
rather foreign concept to me, although I am getting used to it.


L
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: how should I go about downloading files
      • From: Scott Anguish <email@hidden>
    • Re: how should I go about downloading files
      • From: Michael Vannorsdel <email@hidden>
  • Prev by Date: Re: Highlight color of a NSTableView row
  • Next by Date: Question about NSTreeController/NSOutlineView instance cleanup
  • Previous by thread: YACCOB - Yet Another Custom Cell OutlineView Binding problem
  • Next by thread: Re: how should I go about downloading files
  • Index(es):
    • Date
    • Thread