如果用户关闭应用程序,我是否可以包含一个运行一次的函数?如果是,我应该把那个函数放在哪里,因为我不知道用户将从哪个视图控制器关闭应用程序。解决办法是什么?

最佳答案

AppDelegate.swift

func applicationWillTerminate(_ application: UIApplication) {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

关于swift - 用户关闭应用程序后如何在哪里执行功能?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40290480/

10-10 20:41