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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:49:27+00:00 2026-06-01T13:49:27+00:00

In my application I load information from several (6-10) websites using NSXMLParser and then

  • 0

In my application I load information from several (6-10) websites using NSXMLParser and then load the information into views.

Right now, my applications is set up so that it loops through the sites in viewDidLoad in my main view controller and loads them each in a background thread that I created. It does this in a background thread so that the user does not have to wait for all of the sites to load before the view loads.

for (NSMutableDictionary *dict in self.sitesArray) {
    SiteData *data = [[SiteData alloc] init];
    [data setDelegate:self];
    dispatch_async(backgroundQueue, ^(void) {
        [data loadSite:[dict objectForKey:@"SiteName"]];
    });

}

In SiteData, I load the site using NSXMLParser (all of the delegate methods also implemented properly)

-(void)loadSite:(NSString *)site{
    NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:[self fullURLForSiteName:site]];
    [parser setDelegate:self];
    [parser parse];
    return;
}

When the NSXMLParser has finished the document and the SiteData instance is populated with the site’s data, it passes itself to a method in my main view controller on the main thread.

- (void)parserDidEndDocument:(NSXMLParser *)parser{    
    dispatch_async(dispatch_get_main_queue(), ^(void) {
         [delegate successfullyLoadedSite:self];
    });
}

successfullyLoadedSite: loads the passed site’s data into a view and displays it to the user. Note that multiple site’s data are displayed on the same screen.

What I want to happen: I want each site’s data to appear on the screen as it is loaded, not having to wait until all of them finish loading for the view to refresh.

What is happening: One of the sites loads and displays, then I have to wait for all of the rest to load, then all the rest get displayed at once.

From console logging it seems that once it calls successfullyLoadedSite: on the main queue the first time, everything gets run on the main queue. Once the first successfullyLoadedSite: on the main queue gets called, it loads all of the sites into objects, then loads them into views.

Any ideas what’s going on? If you can’t tell I’m new to multithreading. Thanks 🙂


Edit:
I create backgroundQueue like this:

dispatch_queue_t backgroundQueue;

and in init

backgroundQueue = dispatch_queue_create("uni.que.identifier.bgqueue", NULL);

and release it in dealloc with:

dispatch_release(backgroundQueue);
  • 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-01T13:49:28+00:00Added an answer on June 1, 2026 at 1:49 pm

    The queue of using dispatch_queue_create function to create is serial queue,
    then dispatch_queue_create submitted block will execute as sequential order.

    use:

    dispatch_queue_t backgroundQueue =
        dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a flash application that is getting information from a remote server using
My application load asynchronously a big amount of information from a web service and
I have the following code in my application to load some data from my
In our application (c++) we load 3rd party DLLs using LoadLibrary. Sometimes these DLLs
I have couple resource DLLs that I currently load when application starts using following
I have windows mobile application that display information from an sql server ce. Normally
I have written an application which loads information from a plist which lies on
Summary: How do I configure my facebook application to request additional information from the
I've been asked to make an ETL-style application that transfers information from one data
I have a C++ application that loads lots of data from a database, then

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.