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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:24:29+00:00 2026-06-14T03:24:29+00:00

I have 5 html request to get data from web service. I am requesting

  • 0

I have 5 html request to get data from web service. I am requesting in for loop.

-(void)loadPreviewsData
{
    NSMutableURLRequest *request;
    for (int i=1; i<=5; i++) 
    {
        if(i==1)
        {
            //request 1

        }
        if(i==2)
        {
           //request 2
        }
        //3 to 5 

       request.HTTPMethod = @"POST";

   NSURLConnection *myConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];

    if(myConnection)
    {
         HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
         HUD.labelText=@"Please wait.";
         myData = [[NSMutableData alloc] initWithLength:0];

    }
    else 
    {
        UIAlertView  *alert=[[UIAlertView alloc]initWithTitle:@"Message" message:@"Connection could not be established!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }

}// end for loop
}//end loadPreview

all response has a lot of data and i am saving response data into array, but it is not waiting for first response and making another request.
finally for loop will finish and next view will load but array is not filled because parsing is not done yet because copy of data into array is not completed so there is an error.

i tried to sleep(5); in -(void)parserDidEndDocument:(NSXMLParser *)parser method, but it is not valid, because response time is depends on network traffic. i can’t understand what to do please help.

I tried Following answer also but can’t understand Wait for code to finish execution

  • 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-14T03:24:30+00:00Added an answer on June 14, 2026 at 3:24 am

    Probably you are using asynchronous methods with same delegate.
    This means you make the 5 requests at the same time.

    You could make a queue in Grand Central Dispatch:
    http://www.fieryrobot.com/blog/2010/06/27/a-simple-job-queue-with-grand-central-dispatch/

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

Sidebar

Related Questions

I have the following HTML structure being returned from an AJAX request... <th scope=col
I have several HTML elements (buttons) that fire the same JQuery AJAX request. When
hie i have a html form and while posting a request to a url
I have a AJAX request that will return a string that contains some HTML
I have an object in my controller @data=<meta property=\og:url\ content=\<%=SITE_URL%><%=request.request_uri%>\ />.html_safe When I print
I have previously written my web apps with a server side / html template
Using Tornado, I have a Get request that takes a long time as it
I have the following web service: [ScriptService] public class Handler : WebService { [WebMethod]
I tried to use this script pdfmeat to get data about papers from google
I have a POST ASP.Net Web Api method adapted from A guide to asynchronous

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.