作者:Mitchell
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
- 执行UIApplicationMain函数
- UIApplicationMain底层实现:
- 根据principalClassName传递的类名创建UIApplication对象
- 创建UIApplication代理对象,给UIApplication对象设置代理
- 开启主运行时间循环,处理事件,保持程序一直运行
- 加载info.plist,判断下是否指定了main,如果指定了,就会去加载
- 监听系统事件
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- 程序获取焦点
- (void)applicationDidBecomeActive:(UIApplication *)application
- 程序进入后台
- (void)applicationDidEnterBackground:(UIApplication *)application ;
- 程序失去焦点
- (void)applicationWillResignActive:(UIApplication *)application;
- 程序从后台回到前台
- (void)applicationWillEnterForeground:(UIApplication *)application ;
- 程序内存警告,可能要终止程序
-(void)applicationDidReceiveMemoryWarning:(UIApplication *)application;
- 程序即将退出
- (void)applicationWillTerminate:(UIApplication *)application ;