• <bdo id='K3kRu'></bdo><ul id='K3kRu'></ul>

        <small id='K3kRu'></small><noframes id='K3kRu'>

        <legend id='K3kRu'><style id='K3kRu'><dir id='K3kRu'><q id='K3kRu'></q></dir></style></legend>

      1. <tfoot id='K3kRu'></tfoot>

        <i id='K3kRu'><tr id='K3kRu'><dt id='K3kRu'><q id='K3kRu'><span id='K3kRu'><b id='K3kRu'><form id='K3kRu'><ins id='K3kRu'></ins><ul id='K3kRu'></ul><sub id='K3kRu'></sub></form><legend id='K3kRu'></legend><bdo id='K3kRu'><pre id='K3kRu'><center id='K3kRu'></center></pre></bdo></b><th id='K3kRu'></th></span></q></dt></tr></i><div id='K3kRu'><tfoot id='K3kRu'></tfoot><dl id='K3kRu'><fieldset id='K3kRu'></fieldset></dl></div>
      2. Core Data 什么时候刷新到磁盘?

        时间:2023-05-31

          • <bdo id='dP20Z'></bdo><ul id='dP20Z'></ul>
              <tbody id='dP20Z'></tbody>
            <i id='dP20Z'><tr id='dP20Z'><dt id='dP20Z'><q id='dP20Z'><span id='dP20Z'><b id='dP20Z'><form id='dP20Z'><ins id='dP20Z'></ins><ul id='dP20Z'></ul><sub id='dP20Z'></sub></form><legend id='dP20Z'></legend><bdo id='dP20Z'><pre id='dP20Z'><center id='dP20Z'></center></pre></bdo></b><th id='dP20Z'></th></span></q></dt></tr></i><div id='dP20Z'><tfoot id='dP20Z'></tfoot><dl id='dP20Z'><fieldset id='dP20Z'></fieldset></dl></div>
            <legend id='dP20Z'><style id='dP20Z'><dir id='dP20Z'><q id='dP20Z'></q></dir></style></legend>

            <tfoot id='dP20Z'></tfoot>

                  <small id='dP20Z'></small><noframes id='dP20Z'>

                • 本文介绍了Core Data 什么时候刷新到磁盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我在我的应用程序中使用 Core Data,并发现了模拟器的一些奇怪行为:当我在我的应用程序中向 Core Data 添加一些数据并使用 XCode 中的停止"按钮退出模拟器时(或者只需按 Cmd-Q) 立即,下次我启动模拟器时,数据不会存储在数据库中.经过一些测试,我发现数据存储到磁盘:

                  I use Core Data in my application, and discovered some odd behavior of the simulator: When I add some data to Core Data in my app and quits the simulator using the "stop" button in XCode (or just press Cmd-Q) immediately, the data is not stored in the database the next time I start the simulator. After some testing, I found out, that the data is stored to disk:

                  • 当我按下主页按钮时.(几乎 - 如果退出速度非常快,可以在存储数据之前退出应用程序.)
                  • 如果我在添加数据后让应用程序运行一段时间(至少大约 20 秒).
                  • immediately if I press the home button. (Almost - it is possible to quit the application before data is stored if quitting very fast.)
                  • If I let the application run for some time (at least about 20 seconds) after adding data.

                  调用 [NSManagedObjectContext save:] 没有帮助.行为是一样的.

                  It does not help to call [NSManagedObjectContext save:]. The behavior is the same.

                  所以我的问题是:这种行为的原因是什么?有没有办法在退出之前强制刷新到磁盘?在设备上运行时,我是否有可能以这种方式丢失数据(就我个人而言,我没有看到任何风险,除了强制关闭,但奇怪的行为让我有点困扰)

                  So my question is: What is the reason for this kind of behavior? Are there any way to force flushing to disk before quitting? And are there any risk that I can loose data this way when running on a device (personally, I do not see any, except a force close, but the odd behavior bothers me a bit)

                  推荐答案

                  您可能正在使用嵌套上下文.如果你的上下文有一个父上下文,调用 -save: 只会保存到那个上下文,而不是文件系统.

                  You're probably using nested context's. If your context has a parent context, calling -save: will just save to that context, not to the file system.

                  嵌套上下文(通常)用于安全地使用后台队列上的上下文,并允许保存前台上下文而不必产生保存到文件系统的开销.保存到文件系统将在后台队列中进行,不会阻塞主线程.

                  Nested context are (usually) used to safely use a context on a background queue, and allowing a foreground context to save without having to incur the overhead of saving to the file system. The save to the file system will happen on a background queue and not block the main thread.

                  这篇关于Core Data 什么时候刷新到磁盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:模拟位置,包括 Xcode 4.2/iOS5 中的移动 下一篇:在 iphone 中实现 tesseract OCR

                  相关文章

                  最新文章

                    • <bdo id='l1GWp'></bdo><ul id='l1GWp'></ul>

                    <small id='l1GWp'></small><noframes id='l1GWp'>

                  1. <legend id='l1GWp'><style id='l1GWp'><dir id='l1GWp'><q id='l1GWp'></q></dir></style></legend>

                      <i id='l1GWp'><tr id='l1GWp'><dt id='l1GWp'><q id='l1GWp'><span id='l1GWp'><b id='l1GWp'><form id='l1GWp'><ins id='l1GWp'></ins><ul id='l1GWp'></ul><sub id='l1GWp'></sub></form><legend id='l1GWp'></legend><bdo id='l1GWp'><pre id='l1GWp'><center id='l1GWp'></center></pre></bdo></b><th id='l1GWp'></th></span></q></dt></tr></i><div id='l1GWp'><tfoot id='l1GWp'></tfoot><dl id='l1GWp'><fieldset id='l1GWp'></fieldset></dl></div>

                    1. <tfoot id='l1GWp'></tfoot>