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 6250427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:25:16+00:00 2026-05-24T13:25:16+00:00

I am using ASIHTTPRequest to download some data. I have the following in a

  • 0

I am using ASIHTTPRequest to download some data.

I have the following in a method:

// Request 1
request1.tag = 1;
[request1 setDelegate:self];
[request startAsynchronous];

// Request 2
request2.tag = 2;
[request2 setDelegate:self];
[request2 startAsynchronous];

// Call third request method
[self callThirdRequest];

Now from within callThirdRequest, I am grabbing some data that has been downloaded from request2 and in there, I am calling startAsynchronous. The reason I have the calling of the third request in a separate method is because it will get invoked more than once. After putting some console outputs, it seems that callThirdRequest is being invoked before request2 starts its download. Therefore, when callThirdRequest tries to grab some data which should have been downloaded by request2, it does not work as there is no data.

Why is that? How can I make sure callThirdRequest is only called when request2 is done downloading?

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-24T13:25:17+00:00Added an answer on May 24, 2026 at 1:25 pm

    When a request is run asynchronously, the rest of your code will continue to run at the same time. Your first two requests are doing exactly that. You have two options.

    You can run the second request synchronously. (Not a good idea, since your app will appear “frozen” until the second request completes. Also, using this method won’t help you if the second request, in your list of three, fails.)

    A much better idea would be to use delegate callback methods. This is the better way of dealing with this, for two reasons. First of all, you can handle failed requests properly, and also, you can handle successful requests properly. Yu want something like this:

    // Request 2
    request2.tag = 2;
    [request2 setDelegate:self];
    [request2 startAsynchronous];
    
    
    
    - (void)requestFinished:(ASIHTTPRequest *)request{
       if(request.tag == 2){
         [self callThirdRequest];
       }
    }
    

    Make sure to check the request in the delegate callback, to ensure that it’s the “second” one, so that you don’t end up firing the wrong action at the wrong time. In this case, I used the “tag” property of the request. If you would have retained the request as a property of your class, you can just check for that as well.

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

Sidebar

Related Questions

I want to download a file using ASIHTTPRequest, with the following method: ASIHTTPRequest *request;
I'm using ASIHTTPRequest API to get some JSON data from a web side. I'm
I am using ASIHTTPRequest to fetch some data from a web service. I am
I got some question is using ASIHTTPRequest to tracking Upload/Download progress This is the
I'm using ASIHTTP for download some documents from a server. I have a button
I am using ASIHTTPREQUEST in an iPhone project to get some data that looks
I'm using ASIHTTPRequest to download data from the internet. If I lose my internet
I am using the ASIHTTPRequest class to download and upload data.Can any one explain
I am downloading data from different links using ASIHTTPRequest and NSOperationQueue to download in
I'm using ASIHTTPRequest [request startAsynchronous] functon to send a request to my webservice api

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.