views:

121

answers:

3

I have an iphone app that has one view that needs to fetch a lot of data off of a variety of internet sites. Therefore, the amount of time required for it to load is unacceptable. I was wondering if there is any way to load the view during the 'applicationDidFinishLaunching' method so the delay is at the startup of the app instead of midway through navigation.

Thank you very much!

A: 

Have you already considered loading the data asynchronously? While it's loading, the UI doesn't get blocked. For example you can show a nice loading-wheel when your app is loading the data. This is how all good apps do this.

Tim van Elsloo
Yes, but I am making the application sleep at the beginning to show my splash screen anyway so I figured it would be slick to make it do some work during this time. That is my back up plan though - so it still could look pretty cool.
Rossi
A: 

If the initial view has a separate viewController than your 'data' view, you could add a reference to the dataView to the appDelegate and then do something like:

if (self.curAccountManager == nil) {
    self.curAccountManager = [[accountManagerController alloc] initWithNibName:@"accountManager" bundle:[NSBundle mainBundle]];
    if (![self.curAccountManager isViewLoaded]) {
        UIView *tmpView = self.curAccountManager.view;
        tmpView = nil;
    }   



}

This will load the view. But if it's doing a lot of loading, when the user switches to it, it might not respond well. I would suggest you follow the suggestion above and in your data view load the data asynchronously so you can at least show the user status or partial results.

joelm
yeah, thanks - I am going to go with the asynchronous loading - its almost perfect that way - some slight lag and wheel spinning but I'll get over it. Thank you for your help!
Rossi
+1  A: 

You want to load the view as quickly as possible, and then launch a background thread or asynch request to pull the data down.

Making your application sleep during initial load isn't advisable. I believe SpringBoard will terminate any application which takes longer than 30 seconds to finish loading.

It's a bad user experience to have the app do something without visible feedback to the user (animated UIActivityView for example)

chilitechno.com
I wanted to make it sleep for like 4 seconds, not 30 - just to display the splash screen because its pretty cool but I'm going with the asynchronous loading and wheels. I'm mostly satisfied with that. Thank you for your help!
Rossi