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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:59:58+00:00 2026-05-22T22:59:58+00:00

I am am trying to get multiple NSURLConnections to run in parallel (synchronously), however

  • 0

I am am trying to get multiple NSURLConnections to run in parallel (synchronously), however if it is not running on the main thread (block of code commented out below) the URL connection doesn’t seem to work at all (none of the NSURLConnection delegate methods are triggered). Here is the code I have (implementation file of an NSOperation subclass):

- (void)start
{
    NSLog(@"DataRetriever.m start");
    if ([self.DRDelegate respondsToSelector:@selector(dataRetrieverBeganExecuting:)])
        [self.DRDelegate dataRetrieverBeganExecuting:identifier];

    if ([self isCancelled]) {
        [self finish];
    } else {

        /*
        //If this block is not commented out NSURLConnection works, but not otherwise
        if (![NSThread isMainThread])
        {
            [self performSelectorOnMainThread:@selector(start) withObject:nil waitUntilDone:NO];
            return;
        }*/

        SJLog(@"operation for <%@> started.", _url);

        [self willChangeValueForKey:@"isExecuting"];
        _isExecuting = YES;
        [self didChangeValueForKey:@"isExecuting"];

        NSURLRequest * request = [NSURLRequest requestWithURL:_url];
        _connection = [[NSURLConnection alloc] initWithRequest:request
                                                      delegate:self];
        if (_connection == nil)
            [self finish];
    } //not cancelled


}//start

Ran through it with a debugger, and after the end of this start method none of the NSURLConnection delegates trigger (I set breakpoints there). But on the main thread it works just fine. Any ideas of what’s up? 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-22T22:59:59+00:00Added an answer on May 22, 2026 at 10:59 pm

    Background threads don’t automatically have an active run loop on them. You need to start up the run loop after you create the NSURLConnection in order to get any input from it. Fortunately, this is quite simple:

    [[NSRunLoop currentRunLoop] run];
    

    When you say that you are running the connections synchronously, you are incorrect. The default mode of NSURLConnection is asynchronous — it creates and manages a new background thread for you, and calls back to the delegate on the original thread. You therefore don’t need to worry about blocking the main thread.

    If you do actually want to perform a synchronous connection, you would use sendSynchronousRequest:returningResponse:error:, which will directly return the data. See “Downloading Data Synchronously” for details.

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

Sidebar

Related Questions

I'm trying get values from a GridView using the following code: foreach (GridViewRow row
I have a question about the JFileChooser in Swing. I'm trying to get multiple
I am trying to get a multiple upload library working for my Codeigniter based
I am trying to get a multiple countdown system, event day and minutes being
I'm trying to get a bit of code working. I'm using xfade, latest version.
I'm trying to get data from multiple XML feeds and copy that data to
I have a tricky situation in trying to get information from multiple queries into
I'm trying to get multiple tabs in windows like vim does it. In vim
I'm trying to get the values from multiple textboxes using JQuery. I'm a bit
I'm trying to get a jQuery selector for the child of a sibling (multiple

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.