关于UIApplicationMain

 The main.m File and the UIApplicationMain Function

The main function in main.m calls the UIApplicationMain function within an autorelease pool.

@autoreleasepool {
   return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
The @autoreleasepool statement supports memory management for your app. Automatic Reference Counting (ARC) makes memory management straightforward by getting the compiler to keep track of who owns an object; @autoreleasepool is part of the memory management infrastructure.

The call to UIApplicationMain creates two important initial components of your app:

An instance of the UIApplication class, called the application object.
The application object manages the app event loop and coordinates other high-level app behaviors. The UIApplication class, defined in the UIKit framework, doesn’t require you to write any additional code to get it to do its job.
An instance of the AppDelegate class, called the app delegate.
Xcode created this class for you as part of setting up the Single View Application template. The app delegate creates the window where your app’s content is drawn and provides a place to respond to state transitions within the app. The app delegate is where you write your custom app-level code. Like all classes, the AppDelegate class is defined in two source code files in your app: in the interface file, AppDelegate.h, and in the implementation file, AppDelegate.m.
As your app starts up, the application object calls predefined methods on the app delegate to give your custom code a chance to do its job—that’s when the interesting behavior for an app is executed. 
posted on 2015-07-17 03:56  88123  阅读(153)  评论(0编辑  收藏  举报