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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:30:30+00:00 2026-06-07T19:30:30+00:00

On iOS, can you make a synchronous network request (off the main thread) and

  • 0

On iOS, can you make a synchronous network request (off the main thread) and get progress callbacks (on a separate, non-main thread)?

I have have a serial (one-operation-at-a-time) background queue that runs all of time-consuming jobs that don’t need to finish right now. I do want to show progress for the download jobs though. It doesn’t look like you can instantiate an NSURLConnection and configure a delegate, start synchronous connection, and then get progress callbacks.

Is there a way to make a synchronous request on that background queue (synchronous in that the job behind it doesn’t start until its done), and still get setProgress: callbacks which could be sent to update a progressbar? (Callbacks would have to be on a different queue thread, since my serial queue’s thread is blocked until the request is finished.)

Apple’s docs for NSURLConnection say that the synchronous request is actually built on top of the asynchronous behind the scenes. Do I have to re-implement that? I need a way to block a thread until the request finishes/fails. The best leads I have so far are NSOperationQueue‘s waitUntilFinished method, but I don’t want to start async and continually poll on the synchronous method.

NSURLConnection Discussion

A synchronous load is built on top of the asynchronous loading code made available by the class. The calling thread is blocked while the asynchronous loading system performs the URL load on a thread spawned specifically for this load request. No special threading or run loop configuration is necessary in the calling thread in order to perform a synchronous load.

  • 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-07T19:30:32+00:00Added an answer on June 7, 2026 at 7:30 pm

    Reimplementing a synchronous request on top of an asynchronous request is not that hard. You just need to manually spin the thread’s run loop until you see that the request has finished (or failed). Here’s a rough example:

    NSURLRequest *downloadRequest = [NSURLRequest requestWithURL:queryURL];
    // Start the download and wait until it finishes
    self.downloadFinished = NO;
    self.downloader = [NSURLConnection connectionWithRequest:downloadRequest delegate:self];
    
    while (!self.isDownloadFinished)
     {
        [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
     }
    

    Here are the relevant NSURLConnectionDelegate methods:

     - (void)connectionDidFinishLoading:(NSURLConnection *)connection;
     {
        self.downloadFinished = YES;
     }
    
     - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error;
     {
        NSLog(@"An error occurred: %@", error);
        self.receivedData = nil;
        self.downloadFinished = YES;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I added a UISlider in interface builder in my iOS application. Can I make
Anybody can tell me how to make Twitter's row menu in iOS app like
Is there a way in iOS app programming that I can make an user
How can I make a screenshot programmatically in iOS?
If I create my own custom Application for iOS (XCode/Objective-C), can I make it
I'm trying to connect to facebook from my iOS application, so I can make
I have heard about Flash Builder 4.5.1.As I have understood, one can make an
How can I make a custom view in iOS which appears above the existing
i'm studying iOS programming. i have to handling an image. i must make an
As we all know tracking the position of a moving iOS device can be

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.