iOS 监测程序被杀死

[[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(@"程序被杀死");
    }
    写上你的本地通知方法

最后,希望这篇文章能帮到你。

你可能感兴趣的:(iOS 监测程序被杀死)