applicationShouldTerminate not called in AppDelegate and NSApplicationWillTerminateNotification not being sent

旧巷老猫 提交于 2019-12-02 03:18:40

问题


I'm on XCode 11.1 on latest Catalina and none of my app's quit events are being called. applicationShouldTerminate in the AppDelegate nor do I get NSApplicationWillTerminateNotification if I observe it from anywhere. This is from the default quit behavior (Using the menu quit command, Command-Q, or closing the window with applicationShouldTerminateAfterLastWindowClosed returning YES) from the XCode app template using the default storyboard.

This happens with a brand new Xcode project template (If I start a new macOS "App" template, then add the applicationShouldTerminate method to the app delegate).

Other delegate methods like applicationShouldTerminateAfterLastWindowClosed are being called.

Am I doing something horribly wrong or is something messed up with Catalina?


回答1:


Well, I figured it out and it's because it seems that NSSupportsSuddenTermination is on by default now.




回答2:


NSSupportsSuddenTermination is also called 'Application can be killed immediately when user is shutting down or logging out' within Xcode, and seems enabled by default.

Thanks @toastie



来源:https://stackoverflow.com/questions/58491810/applicationshouldterminate-not-called-in-appdelegate-and-nsapplicationwilltermin

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