Domanda

If I'm trying to reduce the load time for my app (that is, the time that the launch image is visible before the initial View Controller appears), where should I focus my efforts? I've found a few questions (like this) that deal with long launch times, but they seem to focus on the performance of the first View Controller exclusively. I'm looking more for info on the very beginning of the app's life cycle, and what methods are called that I might be able to clean up to improve that launch-image duration.

I imagine application:didFinishLaunchingWithOptions: in AppDelegate probably gets called in that time window, but does anything else? Assume a basic app design from an Xcode template, with no unusual build rules or anything like that. Aside from didFinishLaunching and the loading methods of the first view controller, is there anywhere else I should be looking?

È stato utile?

Soluzione

You should probably learn to use Instruments to figure out what your program is doing. The "Time Profiler" instrument would be a good place to start.

It's almost impossible to answer this in the abstract. The real answer is "it depends on how your app is written."

The system will invoke the init method on your app delegate, as well as the class method +initialize (if you have one - you probably don't.)

If you're using storyboards, the system will open your app's storyboard and figure out which view controller is the root view controller. It will load that view controller and invoke it. So all the methods involved in invoking that view controller will fire.

Once that is done, your didFinishLaunching:withOptions method will be called. You should make sure this method doesn't do anything that takes a long time, like downloading content from the internet.

If you do need to download content at launch, you should do it asynchronously.

Altri suggerimenti

You are correct. Also make sure that your first viewcontrollers pre-appearance methods are light (e.g. init, viewDidLoad, viewWillAppear).

To verify which mathods really impactyou can place NSThreads sleepForTimeInterval at strategic points. Only during debugging/ development of course.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top