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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:21:42+00:00 2026-06-12T06:21:42+00:00

I have realized that these two urls do not returns data at the same

  • 0

I have realized that these two urls do not returns data at the same time. I would like to know how I could able to make sure that urls return at the same time. How could I able to change this code to GCD. Is that recommended? I have created dispatch queue in the code but it does not plot anything, not working. without GCD it works but it does not return at the same time. Any help would be appreciated!

-(void)httpRequest{

_weak ASIHTTPRequest *request1 = [ASIHTTPRequest requestWithURL:url1];
[request1 setCompletionBlock:^{
    NSString *responseString1 = [request1 responseString];
//dispatch_async(backgroundProcess1,^(void){
    [self plotOverlay1:responseString1];
 //});
}];
[request1 setFailedBlock:^{
    NSError *error=[request1 error];
    NSLog(@"Error: %@", error.localizedDescription);
}]; 

[request1 startAsynchronous];


_weak ASIHTTPRequest *request2 = [ASIHTTPRequest requestWithURL:url2];
[request2 setCompletionBlock:^{
    NSString *responseString2 = [request2 responseString];
 //dispatch_async(backgroundProcess2,^(void){
    [self plotOverlay2:responseString2];
  //});
}];
[request2 setFailedBlock:^{
    NSError *error=[request2 error];
    NSLog(@"Error: %@", error.localizedDescription);
}]; 

[request2 startAsynchronous];


}
  • 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-06-12T06:21:43+00:00Added an answer on June 12, 2026 at 6:21 am

    There’s no way you can guarantee two independent asynchronous requests will return at the same time.

    One solution would be to chain the requests — in other words, start the second request in the completion block of the first request — and then do processing for both requests in the completion block of the second request.

    Another way that would allow both requests to run in parallel would be to create properties on your class to hold the responses from the requests. In the request completion handlers you would set the appropriate property to the value of the response string, and then call a new method. That method would check to see if the responseString properties from both requests had a value, and if so, do your processing, and if not, do nothing. This way, nothing will happen whenever the one request finishes (and it won’t matter which finishes first) but your processing will be done (for both requests) once the other request has also finished.

    -(void)httpRequest
    {
        _weak ASIHTTPRequest *request1 = [ASIHTTPRequest requestWithURL:url1];
        [request1 setCompletionBlock:^{
            self.responseString1 = [request1 responseString];
            [self checkIfBothRequestsComplete];
        }];
        [request1 startAsynchronous];
    
        _weak ASIHTTPRequest *request2 = [ASIHTTPRequest requestWithURL:url2];
        [request2 setCompletionBlock:^{
            self.responseString2 = [request2 responseString];
            [self checkIfBothRequestsComplete];
        }];
        [request2 startAsynchronous];
    }
    
    - (void)checkIfBothRequestsComplete
    {
        if (self.responseString1 && self.responseString2) {
            [self plotOverlay1:self.responseString1];
            [self plotOverlay2:self.responseString2];
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have realized that these two queries do not work if 'fk_building' is null.
I have an existing view that returns data in the following format based on
I have a KnockoutJS template that looks something like this: <div data-bind=template: {name: 'testTemplate',
I have data.frame that contains several factors and i want to rename factor levels
I'd like to know what would be the best strategy to compare a group
I currently have a script that takes 1,000 rows at a time from a
I have a list of objects that contain row data for a table. There
As I have learned data structure, I know there are plenty of other data
Normally, one would expect, and hope, that two casts are needed to first unbox
I have a save function for my order entity that looks like this and

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.