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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to