抱歉重复问题,经过长时间研究“如何在 applicationWillTerminate() 中调用 Api”但一无所获。有两种解决方案,但有些方法对我不起作用。解决方法发现:当用户终止应用时,我可以进行api调用吗?
1 回答
1
如果您的应用程序处于 applicationWillTerminate 状态或应用程序处于终止状态,则您无法调用 API。
应用程序只允许在 applicationWillTerminate 状态中保存即时更改
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
// Saves changes in the application's managed object context before the application terminates.
CoreDataManager.sharedManager.saveContext()
}
于 2021-06-18T13:10:54.643 回答