问题描述
我的AppDelegate
的applicationWillTerminate:
方法中有一些代码,但是我不知道如何测试它是否有效.使用Xcode停止模拟器不会触发它.
I have some code in my AppDelegate
’s applicationWillTerminate:
method but I don’t know how to test if it works. Using Xcode to stop the simulator does not trigger it.
如何在applicationWillTerminate中测试代码??
How do I test the code in applicationWillTerminate:?
请注意,这是特定于模拟器而不是设备的.
Please note that this is specific to the simulator and not the device.
推荐答案
模拟器不会发送applicationWillTerminate:
,因为跳板没有向您发送终止代码(SIGABRT),而LLDB则向您发送.要触发这些委托方法,您必须使用Home Button命令(⌘+⇧+ H),然后拉起多任务抽屉并从此处杀死您的应用程序.您的调试会话将立即终止,并且委托方法将成功触发.
The simulator doesn't send applicationWillTerminate:
because the springboard isn't sending you the kill code (SIGABRT), LLDB is. To trigger those delegate methods, you have to use the Home Button command (⌘+⇧+H), then pull up the multitasking drawer and kill your application from there. Your debugging session will immediately terminate, and the delegate method will fire successfully.
这篇关于为什么不在iOS模拟器中停止应用程序会触发applicationWillTerminate :?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!