在Mac Catalyst中没有NSWindow,只有UIWindow可用。我尝试使用applicationWillTerminate。
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
但是已经太晚了因为Windows已经关上了。
2条答案
按热度按时间ehxuflar1#
如果实现场景代理,则应该能够使用sceneDidDisconnect方法。
https://developer.apple.com/documentation/uikit/uiwindowscenedelegate
wwodge7n2#
在您的viewController中,您可以添加以下内容。当您关闭包含此视图或viewController的窗口时,您可以处理所有任务并退出应用程序