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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:11:04+00:00 2026-05-14T07:11:04+00:00

I’m currently kicking off a background thread to do some REST queries in my

  • 0

I’m currently kicking off a background thread to do some REST queries in my app delegate’s didFinishLaunchingWithOptions. This thread creates some objects and populates the model as the rest of the app continues to load (because I don’t block, and didFinishLaunchingWithOptions returns YES). I also put up a loading UIViewController ‘on top’ of the main view that I tear down after the background initialization is complete.

My problem is that I need to notify the first view (call it the Home view) that the model is ready, and that it should populate itself. The trick is that the background download could have finished before Home.viewDidAppear is called, or any of the other Home.initX methods.

I’m having difficulty synchronizing all of this and I’ve thought about it long enough that it feels like I’m barking up the wrong tree.

Are there any patterns here for this sort of thing? I’m sure other apps start by performing lengthy operations with loading screens 🙂

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-14T07:11:04+00:00Added an answer on May 14, 2026 at 7:11 am

    I usually have a Factory class that’s responsible for wiring all the objects together. The Factory is created by the application delegate in the applicationDidFinishLaunching:

    - (void) applicationDidFinishLaunching: (UIApplication*) app {
         // Creates all the objects that are needed to wire
         // the application controllers. Can take long. We are
         // currently displaying the splash screen, so that we
         // can afford to block for a moment.
         factory = [[Factory alloc] init];
         // Now that we have the building blocks, we can wire
         // the home screen and start the application.
         home = [[factory wireHomeScreen] retain];
         [window addSubview:home.view];
         [window makeKeyAndVisible];
    }
    

    Now if the Factory creation takes long, I simply wait under the splash screen or put up another view that displays spinner until everything is ready. I guess you could use this very scheme if you can perform the initialization synchronously:

    @implementation Factory
    
    - (id) init {
        [super init];
        // Takes long, performs the network I/O.
        someDataSource = [[DataSource alloc] init…];
        return self;
    }
    
    - (id) wireHomeScreen {
        // Data source already loaded or failed to load.
        HomeScreen *home = [[HomeScreen alloc] init…];
        [home setDataSource:someDataSource];
        return [home autorelease];
    }
    
    @end
    

    With a bit of luck there’s just a single long operation in your startup routine, so that you won’t lose anything by serializing the init.

    If you want to perform the data source init in background, you can display some introductory screen that will cue the home screen once the data has been loaded:

    - (void) applicationDidFinishLaunching: (UIApplication*) app
    {
         // Create the basic building blocks to wire controllers.
         // Will not load the data from network, not yet.
         factory = [[Factory alloc] init];
         // Display something while the data are being loaded.
         IntroScreen *intro = [[IntroScreen alloc] init];
         // Main screen, will get displayed once the data are loaded.
         home = [[factory wireHomeScreen] retain];
         // The intro screen has to know what do display next.
         [intro setNextScreen:home];
         // Start loading data and then notify the intro screen
         // that we are done loading and the show can begin.
         [factory.someDataSource startLoadingAndNotify:intro];
         [window addSubview:intro.view];
         [window makeKeyAndVisible];
    }
    

    Now when the data source has finished loading the data, it will tell the intro screen to cue the real content (home screen, in this case). This is just a rough sketch (for example the memory management might be different in the real case), but in principle it should work fine.

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

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I have a JSP page retrieving data and when single or double quotes are
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
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.