Hi fellow Stackoverflow users,
I am trying to optimize my iphone application startup time (i.e make the first view appear as soon as possible once the app is open). The section I want to optimize is the initialization of the Core Data stack (managed object context, persistent store coordinatorm, etc…) in the application delegate. I thought of two ways to solve this problem and wonder what are you thoughts(pros/cons) on those solutions (or other you may have) ?
Note: The Core Data Stack is initialized in the application delegate for the reasons given in Where to place the "Core Data Stack" in a Cocoa/Cocoa Touch application
Solution 1 (my prefered one):
Initialize the Core Data Stack in a background thread from the application delegate. This will allow the application initialization to be faster and the window/view to be displayed sooner.
Lazy instantiate the Core Data Stack when a view controller requires access to the Core Data Stack. I like this idea however, the Core Data Stack should be initialized in the application delegate and then be passed on in each view controller which requires it.
Note: This solution breaks the convention of initializing the Core Data Stack in the application delegate.