I start with the flow of ios application execution.
As soon as app icon is pressed it would call applicationDidFinishLaunchingWithOptions method with the options Dictionary which contains reasons for the launch.
UIApplicationDelegate protocol is declared in UIKit Framework
Main task:
UIApplicationDelegate's main task is to track the state transitions the application goes through while its running.
The methods in the delegate are provide you with the information about key events in an application's execution such as when it finished launching,when its about to terminate etc.,
The
UIApplication
class provides a centralized point of control and coordination for applications running on iOS.
Every application must have exactly one instance of
UIApplication
(or a subclass of UIApplication
). When an application is launched, theUIApplicationMain
function is called; among its other tasks, this function creates a singleton UIApplication
object. Thereafter you can access this object by invoking the sharedApplication
class method.
Returns the singleton application instance.
+ (UIApplication *)sharedApplication
Return Value
The application instance is created in the
UIApplicationMain
function.UIApplicationMain
This function is called in the
main
entry point to create the application object and the application delegate and set up the event cycle.int UIApplicationMain ( int argc, char *argv[], NSString *principalClassName, NSString *delegateClassName );
Parameters
- argc
- The count of arguments in argv; this usually is the corresponding parameter to
main
. - argv
- A variable list of arguments; this usually is the corresponding parameter to
main
. - principalClassName
- delegateClassName
- The name of the class from which the application delegate is instantiated. If principalClassName designates a subclass of
UIApplication
, you may designate the subclass as the delegate; the subclass instance receives the application-delegate messages. Specifynil
if you load the delegate object from your application’s main nib file.
Return Value
Even though an integer return type is specified, this function never returns. When users exits an iPhone application by pressing the Home button, the application moves to the background.
Discussion
This function instantiates the application object from the principal class and and instantiates the delegate (if any) from the given class and sets the delegate for the application. It also sets up the main event loop, including the application’s run loop, and begins processing events. If the application’s
Info.plist
file specifies a main nib file to be loaded, by including the NSMainNibFile
key and a valid nib file name for the value, this function loads that nib file.As soon as app icon is pressed it would call applicationDidFinishLaunchingWithOptions method with the options Dictionary which contains reasons for the launch.
UIApplicationDelegate protocol is declared in UIKit Framework
Main task:
UIApplicationDelegate's main task is to track the state transitions the application goes through while its running.
- Prior to iOS 4.0 application's state are active,inactive/not running
- In iOS 4.0 or later applications can be running in the background or suspended.
The methods in the delegate are provide you with the information about key events in an application's execution such as when it finished launching,when its about to terminate etc.,