The centralized point of control and coordination for apps running in iOS.
SDKs
- iOS 2.0+
- tvOS 9.0+
Framework
- UIKit
Declaration
class UIApplication : UIResponder
Overview
Every iOS app has exactly one instance of UIApplication (or, very rarely, a subclass of UIApplication). When an app is launched, the system calls the UIApplication function; among its other tasks, this function creates a Singleton UIApplication object. Thereafter you access the object by calling the shared class method.
A major role of your app’s application object is to handle the initial routing of incoming user events. It dispatches action messages forwarded to it by control objects (instances of the UIControl class) to appropriate target objects. The application object maintains a list of open windows (UIWindow objects) and through those can retrieve any of the app’s UIView objects.
The UIApplication class defines a delegate that conforms to the UIApplication protocol and must implement some of the protocol’s methods. The application object informs the delegate of significant runtime events—for example, app launch, low-memory warnings, and app termination—giving it an opportunity to respond appropriately.
Apps can cooperatively handle a resource, such as an email or an image file, through the open method. For example, an app that calls this method with an email URL causes the Mail app to launch and display the message.
The APIs in this class allow you to manage device-specific behavior. Use your UIApplication object to do the following:
Temporarily suspend incoming touch events (
begin)Ignoring Interaction Events() Register for remote notifications (
register)For Remote Notifications() Trigger the undo-redo UI (
application)Supports Shake To Edit Determine whether there is an installed app registered to handle a URL scheme (
can)Open URL(_:) Extend the execution of the app so that it can finish a task in the background (
begin,Background Task(expiration Handler:) begin)Background Task(with Name: expiration Handler:) Schedule and cancel local notifications (
schedule,Local Notification(_:) cancel)Local Notification(_:) Coordinate the reception of remote-control events (
begin,Receiving Remote Control Events() end)Receiving Remote Control Events() Perform app-level state restoration tasks (methods in the Managing the State Restoration Behavior task group)
Subclassing Notes
Most apps do not need to subclass UIApplication. Instead, use an app delegate to manage interactions between the system and the app.
If your app must handle incoming events before the system does—a very rare situation—you can implement a custom event or action dispatching mechanism. To do this, subclass UIApplication and override the send and/or the send methods. For every event you intercept, dispatch it back to the system by calling [super send after you handle the event. Intercepting events is only rarely required and you should avoid it if possible.