iOS 监测程序被杀死
2019-10-10 本文已影响0人
周无恋
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:@"UIApplicationDidEnterBackgroundNotification" object:nil]
- (void)applicationWillTerminate:(UIApplication *)application {
// 业务逻辑
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(comeHome:) name:@"UIApplicationDidEnterBackgroundNotification" object:nil];
-
(void)comeHome:(UIApplication *)application {
NSLog(@"进入后台");
} -
(void)applicationWillTerminate:(UIApplication *)application {
NSLog(@"程序被杀死");
} -
(void)applicationWillTerminate:(UIApplication *)application {
NSLog(@"程序被杀死");
}
写上你的本地通知方法
最后,希望这篇文章能帮到你。