Why doesn’t stopping an application in iOS simulator trigger applicationWillTerminate:?

旧时模样 提交于 2019-12-19 05:20:48

问题


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.

How do I test the code in applicationWillTerminate:?

Please note that this is specific to the simulator and not the device.


回答1:


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.




回答2:


In iOS 9.1 (perhaps before) this only seems to work if you double click home and drag the app up so it exits. Doing it from the desktop doesn't fire this event, it has to happen while the app is open in the simulator.



来源:https://stackoverflow.com/questions/14079670/why-doesn-t-stopping-an-application-in-ios-simulator-trigger-applicationwillterm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!