Application object

An application object is responsible for the initial routing of user events and overall management of a running application. When an application is launched, it creates the application object in its main function. Within an application’s main event loop, the application object takes an incoming event (representing a user action) and routes it to the window containing the view that is the focus of the action. It also receives action messages from controls and forwards them to the appropriate targets. It maintains a list of its windows and manages their current status.

An Application Object Informs its Delegate of External Events

An application object also receives notifications from the operating system when external events affect the application itself—for example, when the user is shutting down the computer or, in iOS, when available memory is low. The application object enlists the help of its delegate in managing these external events as well as events related to the life cycle of the application. It informs the delegate of these events and, in some cases, acts upon the delegate’s response to its messages.


An Application Has a Single Application Object

The application object is a singleton—that is, a single instance is available to all objects in an application. In iOS, the application object is an instance of the UIApplication class (or a subclass of that class); in OS X, the application object derives from the NSApplication class. In both OS X and iOS, you can access the application object by invoking the class message sharedApplication.

Definitive Discussion

Sample Code Projects