Were the delegate
property ever to be nil
, the app would be in an unrecoverable state.
class UIApplication
Declaration
unowned(unsafe) var delegate: UIApplicationDelegate?
Discussion
Every app must have an app delegate object to respond to app-related messages. For example, the app notifies its delegate when the app finishes launching and when its foreground or background execution status changes. Similarly, app-related messages coming from the system are often routed to the app delegate for handling. Xcode provides an initial app delegate for every app and you should not need to change this delegate later.
Why is UIApplicationDelegate.delegate
defined as an optional? A nil
value would be non-recoverable?
Actually, if I were to subclass UIApplication then I might be able to recover from delegate
set to nil
? Is this maybe why?
Here is a related question, but the AppDelegate
is what holds the entire app together. I don't think it could be nil
.