App Delegate 的方法 willTerminate 什么时候执行? [英] When App Delegate's method willTerminate is executed?

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

问题描述

目前我正在测试 AppDelegate 方法,当它们通过将 NSLog 添加到每个方法来执行时.我不清楚的是什么时候执行 applicationWillTerminate 方法?我试图将应用程序置于后台,然后终止它,但未执行来自 Terminate 方法的日志.执行的是这样的:

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

推荐答案

我不清楚的是什么时候执行方法 applicationWillTerminate

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 的方法 willTerminate 什么时候执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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