From 372af86da7031816e687a727846b2742c6c51290 Mon Sep 17 00:00:00 2001 From: Levin Li Date: Sun, 29 Nov 2020 12:59:11 +0800 Subject: [PATCH] Save settings before exit --- MobileCelestia/AppDelegate.swift | 7 ------- MobileCelestia/MainSceneDelegate.swift | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/MobileCelestia/AppDelegate.swift b/MobileCelestia/AppDelegate.swift index cfe512ae..dc20ebc5 100644 --- a/MobileCelestia/AppDelegate.swift +++ b/MobileCelestia/AppDelegate.swift @@ -81,13 +81,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { return true } - func applicationWillTerminate(_ application: UIApplication) { - let core = CelestiaAppCore.shared - if core.isInitialized { - core.storeUserDefaults() - } - } - func application(_ application: UIApplication, shouldSaveApplicationState coder: NSCoder) -> Bool { return false } diff --git a/MobileCelestia/MainSceneDelegate.swift b/MobileCelestia/MainSceneDelegate.swift index 1d901659..cdec42ad 100644 --- a/MobileCelestia/MainSceneDelegate.swift +++ b/MobileCelestia/MainSceneDelegate.swift @@ -11,6 +11,8 @@ import UIKit +import CelestiaCore + @available(iOS 13, *) class MainSceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? @@ -43,6 +45,10 @@ class MainSceneDelegate: UIResponder, UIWindowSceneDelegate { } func sceneDidDisconnect(_ scene: UIScene) { + let core = CelestiaAppCore.shared + if core.isInitialized { + core.storeUserDefaults() + } exit(0) } }