- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
Apple "Concurrency with Core Data" documentation在讨论将核心数据与后台线程一起使用时说明以下内容。
Saving in a Background Thread is Error-prone
Asynchronous queues and threads do not prevent an application from quitting. (Specifically, all NSThread-based threads are “detached”—see the documentation for pthread for complete details—and a process runs only until all not-detached threads have exited.)
特别是:
If you need to save on a background thread, you must write additional code such that the main thread prevents the application from quitting until all the save operation is complete.
在 IOS 应用程序中实现此目标的推荐方法是什么?
最佳答案
在应用程序委托(delegate) applicationWillTerminate
和相关方法中,您需要检查是否有任何后台线程有未保存的更改并在允许应用程序终止或进入后台之前保存它们。
关于ios - 在后台线程上安全保存 Core Data 托管对象上下文的正确方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5752101/
我是一名优秀的程序员,十分优秀!