Ios 强制终止后未调用AppDelegate方法

Ios 强制终止后未调用AppDelegate方法,ios,swift,appdelegate,Ios,Swift,Appdelegate,我试图弄清楚AppDelegate方法是如何工作的 @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptio

我试图弄清楚AppDelegate方法是如何工作的

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        print("didFinishLaunchingWithOptions")
        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        print("willResignActive")
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        print("didEnterBackground")
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        print("willEnterForeground")
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        print("didbecomeActive")
    }

    func applicationWillTerminate(_ application: UIApplication) {
        print("willTerminate")
    }
}
在第一次启动应用程序时,它似乎按照预期工作。 但一旦强制终止应用程序,这些方法将不会被调用

有没有办法在强制终止应用程序后调用这些方法

  • 代码9.2
  • 迅捷4
  • ios11.2在模拟器上的应用

当应用程序启动时,至少会调用
func应用程序(uU2;:didFinishLaunchingWithOptions)
。你凭什么认为不是


请注意,在您强制终止正在运行的应用程序后,您可能拥有的调试器连接将被终止,并且新启动的应用程序不会自动重新连接到调试器。

当您关闭应用程序时,连接将终止。因此,应用程序中的方法不会被调用。因为打印调试即使在强制终止后重新启动,也不会输出。但我第一次听说调试器连接。