- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们知道,当app
被杀死时,在AppDelegate
中,系统会调用applicationWillTerminate:
方法。
但是你知道,如果 archive
是一个 singleton
,这是一个非常重要的事情,而且如果有一个 fetch data
Action , app
是否会在 network
或 archive
尚未完成时被杀死?
我可以在 applicationWillTerminate:
方法中archive
singleton
吗?
applicationWillTerminate:
方法:
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
最佳答案
来自 docs :
Your implementation of this method has approximately five seconds to perform any tasks and return. If the method does not return before time expires, the system may kill the process altogether.
鉴于此信息,如果您确定可以从网络中检索一些信息并在可能不到 5 秒的时间内存档您的对象,那么您可以使用该方法进行操作。
就个人而言,我不会在那里这样做,因为您完全受制于您的互联网连接质量,这很容易导致您的网络请求花费超过 5 秒。
关于ios - 我可以在 `applicationWillTerminate:` 中存档对象吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41115535/
我正在尝试在应用程序终止之前发布一些数据。我通过使用 CFStreamCreatePairWithSocketToCFHost 生成套接字来做到这一点,稍后我有用于读取和写入的回调。 但我无法发布任何
当我的应用程序在 iPhone 模拟器中运行时,委托(delegate)方法 - (void)applicationWillTerminate:(UIApplication *)application
我的应用程序中有一些单独的线程需要正确拆除。如果用户在文件菜单中选择退出菜单项,我会抛出一个错误,提示...请在退出之前停止您正在执行的其他操作。但是,如果用户从 Mac 上的应用程序底座退出该应用程
我实现了 applicationWillTerminate 方法,但它从未被调用 -(void)applicationWillTerminate:(NSNotification *)notificat
无法弄清楚应用终止时会发生什么。 查看 applicationWillTerminate 的苹果文档说: 对于不支持后台执行或链接到 iOS 3.x 或更早版本的应用程序,当用户退出应用程序时始终调用
有没有办法判断我的 Android 应用程序何时终止?在 iOS 中,AppDelegate 中有一个方法 - (void)applicationWillTerminate:(UIApplicatio
我有一个应用程序需要知道它何时崩溃(用于调试目的)。当应用程序关闭时,它会在委托(delegate)中调用 - (void)applicationWillTerminate:(UIApplicatio
什么情况下会调用applicationWillTerminate?例如,如果代码发生崩溃,是否会偶尔调用它? Apple 的文档对此含糊不清,它只说明系统何时因某种原因需要终止它。 For apps
当我的应用程序终止时(通过操作系统或双击主页按钮并终止应用程序),我想取消AllLocalNotifications并将ApplicationIconBadgeNumber设置为0。我只是将这两个调用
您好,我已经阅读了几个关于 applicationWillTerminate 被调用和不被调用的问题。 我想总结一下我的理解,因为有几篇文章的说法不同。 对于 IOS(无多任务处理),按下主页按钮时始
我想在终止之前保存数据,因此我的 AppControll 类符合 NSApplicationDelegate 协议(protocol),并声明了该方法;在界面生成器中,我将窗口的委托(delegate
我正在尝试在 AppDelegate 的 applicationWillTerminate 中发出套接字事件。我使用过socket.io。 我相信我能够成功发出该事件。以下是我在控制台中收到的日志:
我目前正在构建一个支持后台模式的应用程序。仅举几例,我已注册 HealthKit 的后台传送,并且还监视 didEnterRegion 等位置后台事件。据我所知,如果调用这些,iOS 将暂时在后台重新
我正在尝试从加载到 applicationWillTerminate 的 View 中保存我的数据,但遇到了一些问题。 我有四种看法:在 FinateViewController 中FirestVie
我在 Apple 的 iOS 开发中心进行了搜索,但找不到任何合适的东西。这是我的问题: 我有一个将 CoreData 与多个实体一起使用的应用程序。数据通过服务器动态更新。现在,每次应用激活时都会调
有没有办法保证 AppDelegate 委托(delegate)中的 applicationWillTerminate 方法会被命中?像 info.plist 文件中的 key 之类的东西......
在我的应用程序中,当用户终止应用程序时,我需要向服务器发送一些指令。在 applicationWillTerminate func 中,我尝试发送它,但它从未到达服务器。我尝试使用 Alamofire
我想在 iOS 设备上插入时启动我的应用程序,但我找不到任何解决方案,我该怎么做。我想知道,Apple 是否允许在 applicationWillTerminate 函数中启动应用程序? 感谢您的关注
我们知道,当app被杀死时,在AppDelegate中,系统会调用applicationWillTerminate:方法。 但是你知道,如果 archive 是一个 singleton,这是一个非常重
这个问题在这里已经有了答案: When an app crashes does either the 'applicationWillTerminate' or 'applicationDidEnt
我是一名优秀的程序员,十分优秀!