1 , overview
All mobile operating systems have a fatal disadvantage: apps are vulnerable to interruptions. For example, a call or lock screen will cause the app to go backstage or even be terminated.
There are a number of other similar situations that can cause the app to be disturbed, causing some system events when the app is disturbed, and UIApplication notifies its delegate object, allowing delegate agents to handle these system events.
Delegate the events that can be handled include:
(1) Application lifecycle events (such as program startup and shutdown)
(2) System events (such as incoming calls)
(3) Memory warning
(4) ...
2 , uiapplicationdelegate
Every time a new project is completed, there is a class with the word "appdelegate", which is the agent of UIApplication.
Mjappdelegate has complied with the Uiapplicationdelegate protocol by default and is already a proxy for uiapplication.
We can implement the corresponding methods directly in the mjappdelegate as needed, and these methods will be called automatically when the corresponding situation occurs. For example, we can be in Mjappdelegate-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: ( Nsdictionary *) Launchoptions; Creates a controller in the method and sets the Rootviewcontroller to the window.
iOS Development uiapplication and delegate