Search code examples
iphonelaunch

What exactly is happening when I tap my iPhone app icon?


My app takes incredibly long to load, and I have no idea why. To add: It gets stuck on the homescreen for 3-4 seconds before actually bringing up the [email protected].

Can someone tell me what is loading when I tap the icon? Is it the method applicationDidFinishLaunching? Or the resources?


Solution

  • As a very general answer: Apple details this in the section The Application Life Cycle of the iOS Application Programming Guide.

    Of note is the first diagram from the section. Fairly self-explanatory flowchart that follows the introductory paragraph (emphasis mine to address your specific query):

    The application life cycle constitutes the sequence of events that occurs between the launch and termination of your application. In iOS, the user launches your application by tapping its icon on the Home screen. Shortly after the tap occurs, the system displays some transitional graphics and proceeds to launch your application by calling its main function. From this point on, the bulk of the initialization work is handed over to UIKit, which loads the application’s main nib file and readies the event loop.


    (source: apple.com)

    As to why your application is loading slowly, you don't provide any other information so all I can say is to check what resources are being loaded in your nibs,

    • are the images very large, or are there many of them?

    And look at your app delegate's application:didFinishLaunchingWithOptions: method and the relevant setup routines that it may call,

    • if you have any data-loading routines, are they taking everything in your application's documents directory (for example) and loading them into memory in one fell swoop?

    • how is your data stored? Flat/simple files (e.g. XML or plists) may not sound like a big deal since they're just basic I/O, but when it comes to large data stores or complex object relationships, Core Data or SQLite tend to be performantly superior.

    Also, Instruments is your friend.