The AppDelegate is sort of like the entry point for your application. It implements UIApplicationDelegate and contains methods that are called when your application launches, when is going to the background (i.e. when you hit the home key), when it’s opened back up, and more. The AppDelegate object is stored as a property on the UIApplication class and is accessible from anywhere in your objective-C classes. The header and implementation file for your AppDelegate is generated when you create your project and you don’t have to make any modifications for it to work. However, that doesn’t mean we can’t make changes and make use of the AppDelegate. We’re going to keep this simple and just add a newNSString property to the delegate.
AppDelegate is handling special UIApplication states.This lets you do initialization/cleanup of your app at the right time.So basically the delegate is responsible for monitoring when it is safe to open/close things, terminate the app etc, and it talks to the application, and gives it accurate & critical information, with regards to how & when to do these tasks?.
The only way I can imagine it, is a security guard who is called by the staff inside a building, and asked if it is safe to open the security door; he can answer YES or NO
1. applicationDidFinishLaunching: – for handling on-startup configuration and construction. which will be called when the app has finished launching
2. applicationWillTerminate: – for cleaning up at the end You should avoid putting other functionality in the AppDelegate since they don’t really belong there.Many people lump these things into their AppDelegate because they are lazy or they think the AppDelegate controls the whole program. You should avoid centralizing in your AppDelegate since it muddies the areas of concern in the app and doesn’t scale.
a delegate is an object that another object defers to on behavior and informs about changes in its state.
The AppDelegate just sits there doing nothing, waiting to be told that something potentially important will happen. The application/iPhone OS is the one doing the work and calling the AppDelegate and it might want to respond to in your code.