iOS start up procedures

iOS app structure

All apps have a main.m, which contains the app’s entry point, a function called main().

The main() function initializes an “application” object (you can think of this as the runtime environment for the app).

Then, in a typical configuration, the app’s main nib file is loaded. (The name of the nib file is seen in -Info.plist.)

The nib file loads, and by configuration, causes the application delegate to load. The application delegate implements methods that handle application-level events. Then, typically, the app’s initial view and view controller are initialized, and control is passed to the view controller.

After that, user interaction and other events in the environment will determine what happens next.

A typical app, therefore, has the following components (that make up its structure):

main() function, in main.m
configuration info located in -Info.plist
application delegate (AppDelegate.h and .m)
initial view (nib file) and view controller (.h and .m)
other views and view controllers
resources like images and so on
app icon, as a 57px square PNG-format image

iOS app startup

What is the typical startup sequence? What happens, and in what order? The following details the steps:

The app is launched by the user
The main() function is the entry point, and runs
The UIApplicationMain() function is called
The application (singleton) object is created (i.e. the runtime environment for the app)
-Info.plist is examined, and the nib file named in “Main nib file base name” is loaded (which means that all of its objects are initialized, and connections are established)
As part of the nib loading, the awakeFromNib: method is called on all the objects that it initialized
The runtime sends the applicationWillFinishLaunching: message to the application delegate
The nib’s File’s Owner object has an instance variable named “delegate”; the object that it points to is the application delegate, which is then initialized
The runtime sends the application:didFinishLaunchingWithOptions: message to the application delegate

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: