- The design of the UIKit framework incorporates many of the same design patterns found in Cocoa applications in Mac OS X. (MVC, Block objects, Delegation, Target-action, Managed memory model, threads and concurrent programming).
- The UIApplication object manages the application event loop and coordinates other high-level behaviors for your application.
- The application delegate is a custom object that you provide at application launch time, usually by embedding it in your application’s main nib file.The UIApplication object also notifies this object when specific application-level events occur
- View controller objects manage the presentation of your application’s content. Typically, this involves creating the views to present that content and managing the interactions between the views and your application’s data model objects.
- The main Function. In an iOS application, the main function is used only minimally. Its main job is to hand control to the UIKit framework.
- The UIApplicationMain function at the heart of your application’s main function takes four parameters and uses them to initialize the application.The third parameter identifies the name of the application’s principal class. This is the class responsible for running the application.Monitoring the high-level behavior of your application is the responsibility of the application delegate object, which is a custom object that you provide.
- Application states: Not running, Inactive, Active, Background, Suspended
- At launch time, an application moves from the not-running state to the active or background state. During the initial startup sequence, the application calls its delegate’s application:didFinishLaunchingWithOptions: method, followed by either the applicationDidBecomeActive: or applicationDidEnterBackground: method (depending on whether it is transitioning to the foreground or background).
- Check the contents of the launch options dictionary for information about why the application was launched, and respond appropriately.
- You should strive to make your application:didFinishLaunchingWithOptions: method as lightweight as possible. Although there are any number of custom initialization tasks you could perform in this method, it has only around 5 seconds to do its initialization and return. If it takes too long to complete its tasks, the system might kill the application for being unresponsive. Ways to make this method lightweight include initiating tasks asynchronously or moving any long-running tasks to secondary threads. Making the method lightweight is especially important for network-based tasks that could take an indeterminate amount of time to complete.
- When your application:didFinishLaunchingWithOptions: method is called, the applicationState property of the UIApplication object is already set to the appropriate state for your application (UIApplicationStateInactive, UIApplicationStateBackground). you can use this information to prepare your application appropriately.
- "Being a Responsible, Multitasking-Aware Application."
- Your delegate’s applicationDidEnterBackground: method has approximately 5 seconds to finish any tasks and return. If the method does not return before time runs out, your application is killed and purged from memory. If you still need more time to perform tasks, call the beginBackgroundTaskWithExpirationHandler: method to request background execution time and then start any long-running tasks in a secondary thread.
- The UIApplicationDidEnterBackgroundNotification notification is also sent to let interested parts of your application know that it is entering the background.
- To that end, there are at least two things you should always do in your applicationDidEnterBackground: method: Prepare your application to have its picture taken Save user data and application state information
- ....Responding to Interruptions to be continue
last update 30/3/2012