通過添加通知:
//1、添加進(jìn)入后臺的判斷
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(comeHome:) name:@"UIApplicationDidEnterBackgroundNotification" object:nil];
- (void)comeHome:(UIApplication *)application {
NSLog(@"進(jìn)入后臺");
}
//2缺谴、添加程序被殺死的判斷
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:@"UIApplicationWillTerminateNotification" object:nil];
- (void)applicationWillTerminate:(UIApplication *)application {
NSLog(@"程序被殺死");
}