From the course: iOS Development: Architecture

The app delegate

From the course: iOS Development: Architecture

Start my 1-month free trial

The app delegate

- [Instructor] The AppDelegate is the root object of each IOS app. It's a single object and it exists during the lifetime of the app. Whenever we create a new IOS project, Xcode create the AppDelegate for us. The AppDelegate implements the UI application delegate protocol. You can see it here at line 12. The UIApplicationDelegate protocol provides various callback methods. These methods get invoked when the app is about to transition to a different state. The generated AppDelegate code contains some of the UI application delegate methods. We can implement them if you wanna react to these particular state changes. But, it's also completely safe to just delete them. The compiler won't complain since the callback methods are optional. Besides responding to state changes, the AppDelegate has many other responsibilities. It contains our app startup code and it responds to external notifications. We can also add state preservation and restoration logic in the AppDelegate as we've seen in the previous chapter. Next, we dab into the state transitions.

Contents