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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:01:20+00:00 2026-05-18T11:01:20+00:00

I’m in this kind of situation… I want to patch 100 different web requests,

  • 0

I’m in this kind of situation… I want to patch 100 different web requests, but it’s separated in three different functions:

-(void)functionMain {
    for(int i = 0; i < 100; i++)
        [self sendRequestToServer];
}

So that first function will basically send request to some URL and wait for it to finish…

-(void)sendRequestToServer {
    [request sendRequest:mAddress];
    [request didFinishSelector:@"refreshAddress"];
    [request startAsynchronous];
}

This function above will do the actual sending of the address.

-(void)refreshAddress {
    NSString *result = [request getResponse];
    mAddress = [result getTheNextAddress];
    [self refreshDisplay];
}

Now this will set mAddress to the next web address. So I got a lot of this, and apparently one request takes a bit of time (around 600 ms), but if you notice in the main loop in functionMain, I don’t have any mechanism to see whether refreshAddress has finished doing its job, because it it hasn’t then I’ll only be sending request with the same address over and over.

I tried using a boolean variable to guard the loop, but it doesn’t look like it’s working… Is there any graceful way to do this? I’m not sure what should I look for.. I don’t know if NSOperation or NSThread will help me.

EDIT: As I mentioned in the comment, this is probably more like I’m having a multi-threading situation here (to be exact this might be 100 threads) that I want to make into only a single thread.

EDIT: So what I really want is like this (suppose the loop is only 3):

functionMain(i = 0) -> 
sendRequestToServer

Then we wait until that finishes, then we have this:

refreshAddress (mAddress has been set to something else now) -> 
functionMain (i = 1) -> 
sendRequestToServer

Once again:

refreshAddress (mAddress has been set to something else now) -> 
functionMain (i = 2, finished)

Very very sorry if I can’t describe the problem more clearly… I wish I can write better english and can describe things clearer!

  • 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-18T11:01:20+00:00Added an answer on May 18, 2026 at 11:01 am

    Possibly I’m not following you here but if you want them to happen one after the other you should use a synchronous request in NSURLConnection.

    + sendSynchronousRequest:returningResponse:error:
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to count how many characters a certain string has in PHP, but
I'm interested in microtypography issues on the web. I want a tool to fix:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I want to construct a data frame in an Rcpp function, but when I
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.