If my app shuts down because load time takes to long, can I move some code in or being called from applicationDidFinishLa开发者_Python百科unching into the RootViewController? Meaning, is the (shutdown) timer only looking at applicationDidFinishLaunching?
I'm not 100% sure on this, but I believe the timer stops when control returns to the run loop and the application can accept user input, which is generally at the end of your applicationDidFinishLaunching method.
However, if you load a view in applicationDidFinishLaunching, and either your loadView or viewDidLoad takes a long time, you're app may be shutdown by the OS. Alternatively, you can call the method using -performSelector:withObject:afterDelay:
with a delay of 0, and the method will be queued up in the run loop and run as soon as possible.
If you must do a lot of processing before you can hand over control to the user, you should look into performing that load on a background thread.
EDIT: Here's the relevant Technical Q&A.
In general any time consuming stuff should not be done on the main thread. You're applicationDidFinishingLaunching should return as quickly as possible. Both to prevent your app being killed by SpringBoard, but also as a nice experience for the user. Either use performSelector:withObject:afterDelay:
or use NSOperations
to move stuff out of the main thread.
精彩评论