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

  • Home
  • SEARCH
  • 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 6581535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:09:54+00:00 2026-05-25T16:09:54+00:00

I’m having a little problem using NSURLDownload . Basically I’m downloading two different files

  • 0

I’m having a little problem using NSURLDownload. Basically I’m downloading two different files using the following code twice with the variable names changed.

NSURLRequest *requestUserfile = [NSURLRequest requestWithURL:[NSURL URLWithString:requestAgent_url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];

NSURLDownload *downloadUserFile = [[NSURLDownload alloc] initWithRequest:requestUserfile delegate:self];

NSString *uf_tpath = [ [ [NSBundle mainBundle] bundlePath ] stringByAppendingPathComponent:@"userfile"]; 

if (downloadUserFile) {
[downloadUserFile setDestination:uf_tpath allowOverwrite:YES];
} else {
NSLog("ERROR: Problem while downloading user file [1].");
exit(0);
}

But I’ve a problem, according to Apple class reference this code is asynchronous and it calls - (void)downloadDidFinish:(NSURLDownload *)download when the download is finished.

My program needs the two files downloaded to a folder before start doing any processing, so how can I know when the two of them are downloaded? that will be called when the first one is finished :S

My first idea was to place the second file download int the downloadDidFinish of the first one… but then I will run into an infinite loop and I’ll have two methods with the same name :S

PS: I’m new to Obj-C and Xcode, I used to do this using signals and slots on QT but there I can just define two slots different slots and connect them on right time.

Thanks.

  • 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-25T16:09:55+00:00Added an answer on May 25, 2026 at 4:09 pm

    I ended up applying a if statement on the (void)downloadDidFinish:(NSURLDownload *)download to evaluate witch file is already on the disk and then download the other.

    Like

    NSString *file1_path = [ [ [NSBundle mainBundle] bundlePath ] stringByAppendingPathComponent:@"file1"];
    NSString *file2_path = [ [ [NSBundle mainBundle] bundlePath ] stringByAppendingPathComponent:@"file2"]; 
    BOOL f1_is_downdl = [[NSFileManager defaultManager] fileExistsAtPath:file1_path];   
    BOOL f2_is_downdl = [[NSFileManager defaultManager] fileExistsAtPath:file2_path];
    
    
    if ( f1_is_downdl && !(f2_is_downdl) ) { // File 1 is downloaded and the second is not...
    
        [download release];
    
        // Now download the file 2!
        NSString *requestFile2_url = [NSString stringWithFormat:@"http://host.org/software/%@-ag", req_id];
        NSURLRequest *requestFile2 = [NSURLRequest requestWithURL:[NSURL URLWithString:requestFile2_url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
    
        NSURLDownload *downloadFile2 = [[NSURLDownload alloc] initWithRequest:requestFile2 delegate:self];
    
        if (downloadFile2) {
            [downloadAgent setDestination:file2_path allowOverwrite:YES];
        } else {
            NSLog(@"ERROR: Problem while downloading user file [2].");
            exit(0);
        }
    
    } else if (f1_is_downdl && f2_is_downdl) { // Everything is downloaded!
    
        // Do something else.
    
    }
    

    Well… I know that this is probably the worst way in the world to do this but… It’s the way I figured it out.

    Thanks for the info anyway, one day (when I rewrite this with more Obj-C knowage) it might me useful for me.

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

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

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.