何时执行App Delegate的方法将终止? [英] When App Delegate's method willTerminate is executed?

查看:105
本文介绍了何时执行App Delegate的方法将终止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在测试 AppDelegate 方法,当它们通过向每个方法添加 NSLog 执行时。我不清楚的是何时执行方法 applicationWillTerminate ?我试图将应用程序放在后台,然后终止它,但不执行从Terminate方法的日志。执行的是:

  2015-09-01 16:24:01.512 TestQuestions [2351:110179] didFinisLaunching 
2015-09-01 16:24:02.530 TestQuestions [2351:110179] didBecomeActive
2015-09-01 16:24:05.864 TestQuestions [2351:110179] willResign
2015-09- 01 16:24:06.322 TestQuestions [2351:110179] didEnterBackground


解决方案

< blockquote>

我不清楚的是,何时执行方法applicationWillTerminate


几乎从不。它可以在某些罕见的情况下调用,例如在后台播放音乐并从那里终止。但总的来说,你应该期望它永远不会被调用,因为当你被终止时,你已经被暂停,你的代码不再运行(并且系统不会叫醒你只是为了告诉你它正在杀死你在后台)。


currently I am testing AppDelegate methods, when they are executed by adding NSLog to every method. What is not clear to me is when method applicationWillTerminate is executed? I've tried to put app in background, then to terminate it, but log from Terminate method is not executed. What is executed is this:

2015-09-01 16:24:01.512 TestQuestions[2351:110179] didFinisLaunching
2015-09-01 16:24:02.530 TestQuestions[2351:110179] didBecomeActive
2015-09-01 16:24:05.864 TestQuestions[2351:110179] willResign
2015-09-01 16:24:06.322 TestQuestions[2351:110179] didEnterBackground

解决方案

What is not clear to me is when method applicationWillTerminate is executed

Almost never. It can be called under certain rare circumstances where you are e.g. playing music in the background and are terminated from there. But in general you should expect that it will never be called, because by the time you are terminated, you are already suspended and your code is no longer running (and the system is not going to wake you up just to tell you it's killing you in the background).

这篇关于何时执行App Delegate的方法将终止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆