Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6385439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:53:59+00:00 2026-05-25T02:53:59+00:00

I am facing an issue making a queue of asynchronous downloads of 3 files.

  • 0

I am facing an issue making a queue of asynchronous downloads of 3 files.

I would like when I finish to download and saved the first files to start to download the second one then third one …

For the moment I am using 3 IBAction to download into Documents folder and it work perfectly, but to make it automatically for all files didn´t work.

What is the best way to implement the download queue of this files ?
I know i have to had statements on didReceiveData but I need help to make it working.

This is the code I am using :

// Download song 1
- (IBAction)download {

[self performSelector:@selector(downloadmusic) withObject:nil afterDelay:0.0];

}


- (void)downloadmusic
{
self.log = [NSMutableString string];
[self doLog:@"1/13"];

// Retrieve the URL string
int which = [(UISegmentedControl *)self.navigationItem.titleView selectedSegmentIndex];
NSArray *urlArray = [NSArray arrayWithObjects: SONG1_URL, nil];
NSString *urlString = [urlArray objectAtIndex:which];

// Prepare for download
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

// Set up the Download Helper and start download
[DownloadHelper sharedInstance].delegate = self;
[DownloadHelper download:urlString];

}

// Download song 2
- (void)downloadmusic2 
{

self.log = [NSMutableString string];
[self doLog:@"2/13"];

// Retrieve the URL string
int which = [(UISegmentedControl *)self.navigationItem.titleView        selectedSegmentIndex];
NSArray *urlArray = [NSArray arrayWithObjects: SONG2_URL, nil];
NSString *urlString = [urlArray objectAtIndex:which];

// Prepare for download
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

// Set up the Download Helper and start download
[DownloadHelper sharedInstance].delegate = self;
[DownloadHelper download:urlString];


}


// Download song 3
- (void)downloadmusic3 
{

self.log = [NSMutableString string];
[self doLog:@"3/13"];

// Retrieve the URL string
int which = [(UISegmentedControl *)self.navigationItem.titleView selectedSegmentIndex];
NSArray *urlArray = [NSArray arrayWithObjects: SONG3_URL, nil];
NSString *urlString = [urlArray objectAtIndex:which];

// Prepare for download
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];

// Set up the Download Helper and start download
[DownloadHelper sharedInstance].delegate = self;
[DownloadHelper download:urlString];


}



- (void) doLog: (NSString *) formatstring, ...
{
va_list arglist;
if (!formatstring) return;
va_start(arglist, formatstring);
NSString *outstring = [[[NSString alloc] initWithFormat:formatstring arguments:arglist] autorelease];
va_end(arglist);
[self.log appendString:outstring];
[self.log appendString:@"\n"];
[textView setText:self.log];
}

- (void) restoreGUI
{
self.navigationItem.rightBarButtonItem = BARBUTTON(@"Get Data", @selector(action:));
if ([[NSFileManager defaultManager] fileExistsAtPath:DEST_PATH])
    self.navigationItem.leftBarButtonItem = BARBUTTON(@"Play", @selector(startPlayback:));  
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
[(UISegmentedControl *)self.navigationItem.titleView setEnabled:YES];
[progress setHidden:YES];

}

- (void) dataDownloadAtPercent: (NSNumber *) aPercent
{
[progress setHidden:NO];
[progress setProgress:[aPercent floatValue]];
}

- (void) dataDownloadFailed: (NSString *) reason
{
[self restoreGUI];
if (reason) [self doLog:@"Download failed: %@", reason];
}

- (void) didReceiveFilename: (NSString *) aName
{
self.savePath = [DEST_PATH stringByAppendingString:aName];


}

- (void) didReceiveData: (NSData *) theData
{
if (![theData writeToFile:self.savePath atomically:YES])
    [self doLog:@"Error writing data to file"];

[theData release];
[self restoreGUI];
[self doLog:@"Download succeeded"];


//[self performSelector:@selector(downloadmusic2) withObject:nil afterDelay:1.0];


    //[self performSelector:@selector(downloadmusic3) withObject:nil afterDelay:1.0];


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T02:54:00+00:00Added an answer on May 25, 2026 at 2:54 am

    From within your controller, create three blocks and copy them to an array, which will serve as your queue. This array will need to be stored as an instance variable so that it can be accessed by later invocations of methods in your controller class. Each of the three blocks should create and execute an NSURLConnection which asynchronously downloads the appropriate file. The delegate of each NSURLConnection can be your controller, and it should implement the -connectionDidFinishLoading: delegate method. From this method, call a method which pops the first block off the queue and executes it.

    Then just call the method for the first time to start the process. Obviously there is some edge-case and error handling that you need to provide, but this is the basic idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making my first iOS App, and I'm facing my first (little) issue. The
issue facing while loading the messages in to mq channel, recieving an error like
I'm facing issue with redirecting the viewControllers using pop/pushViewControllers. I've three view controller like
I am facing issue while trying into insert special symbols like pound character (£
I am facing issue with proper date retrieval using date formatter.I have saved the
in my web application i am facing a issue after making it live. i
I am facing issue while i load a form on ajax request. i followed
I have been facing issue with sphinx result set for string attribute. Below is
I got below JSON string, i facing issue parsing because it contains non english
We have implemented webservice which generates xml response. I am facing issue while invoking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.