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

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

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

      <tfoot id='fFU1u'></tfoot>
      1. 将两个 SQLite 存储合并为一个

        Combining Two SQLite Stores Into One(将两个 SQLite 存储合并为一个)
          <i id='JzXIy'><tr id='JzXIy'><dt id='JzXIy'><q id='JzXIy'><span id='JzXIy'><b id='JzXIy'><form id='JzXIy'><ins id='JzXIy'></ins><ul id='JzXIy'></ul><sub id='JzXIy'></sub></form><legend id='JzXIy'></legend><bdo id='JzXIy'><pre id='JzXIy'><center id='JzXIy'></center></pre></bdo></b><th id='JzXIy'></th></span></q></dt></tr></i><div id='JzXIy'><tfoot id='JzXIy'></tfoot><dl id='JzXIy'><fieldset id='JzXIy'></fieldset></dl></div>

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

              <tbody id='JzXIy'></tbody>

              <tfoot id='JzXIy'></tfoot>

                  <bdo id='JzXIy'></bdo><ul id='JzXIy'></ul>

                • <legend id='JzXIy'><style id='JzXIy'><dir id='JzXIy'><q id='JzXIy'></q></dir></style></legend>

                • 本文介绍了将两个 SQLite 存储合并为一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  假设我的应用程序文档目录中有两个 SQLite 文件.我将如何将两者组合在一起并将它们保存为包含两者所有信息的单个文件?我真的必须创建两个持久存储协调器并手动协调两者之间的过程,还是有更有效的方法?

                  Say I have two SQLite files in my application documents directory. How would I go about combining the two together and saving them as a single file that contained all the information from both? Do I literally have to create two persistent store coordinators and manually coordinate the process between the two, or is there some more efficient way of doing it?

                  -灰

                  推荐答案

                  你的问题不是你需要问的.Core Data 中的 SQLite 存储仅仅是 Core Data 对象图的后备存储.它是一个 SQLite 数据库这一事实对 Core Data 来说并不重要.所以你的问题实际上是,我如何将两个 Core Data 对象图合并为一个?"

                  Your question isn't quite what you need to ask. A SQLite store in Core Data is merely the backing store for a Core Data object graph. The fact that it's a SQLite database is immaterial to Core Data. So your question is really, "how do I merge two Core Data object graphs into one?"

                  这在某种程度上取决于您要对数据做什么.Core Data 中的一条规则是,您不能在不同持久存储中的两个对象之间建立关系.因此,如果您不需要存储 A 中的对象和存储 B 中的对象之间的关系,那真的很简单.只需将两个持久存储添加到您的 NSPersistentStoreCoordinator,两个存储中的所有对象都可以从与该持久存储协调器关联的任何托管对象上下文中获得.

                  It kind of depends on what you want to do with the data. One of the rules in Core Data is that you can't have relationships between two objects in different persistent stores. So, if you don't have a need for relationships between objects in Store A and objects in Store B, it's really quite simple. Just add both persistent stores to your NSPersistentStoreCoordinator, and all the objects from both stores will be available from any managed object context associated with that persistent store coordinator.

                  如果您确实需要在两个商店中的对象之间建立关系,或者您真的只想拥有一个商店,那么最好的办法是创建第二个 NSPersistentStoreCoordinator 和第三个不同的持久存储来保存合并的对象图.您将需要编写代码以在附加到第二个 NSPersistentStoreCoordinator 的托管对象上下文中创建对象的副本.您还需要在原始对象所具有的副本之间建立相同的关系,但是如何执行此操作取决于您的数据模型.如果您想为您的问题添加更多细节,也许我可以让您更好地了解所涉及的内容.

                  If you do need to have relationships between the objects in both stores, or you really just want to have a single store, your best bet would be to create a second NSPersistentStoreCoordinator and a third, distinct persistent store to hold the merged object graph. You will need to write code to create copies of the objects in a managed object context attached to this second NSPersistentStoreCoordinator. You'll need to set up the same relationships among the copies that the original objects had, too, but how you go about doing this depends on your data model. If you want to add some more detail to your question, maybe I can give you a better idea of what would be involved.

                  这篇关于将两个 SQLite 存储合并为一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  EAAccessory/EASession teardown during background(EAAccessory/EASession 在后台拆除)
                  Getting an NSArray of a single attribute from an NSArray(从 NSArray 获取单个属性的 NSArray)
                  ImageIO: lt;ERRORgt; JPEG Corrupt JPEG data: premature end of data segment iphone - how to catch this?(ImageIO:lt;错误gt;JPEG 损坏的 JPEG 数据:iphone 数据段过早结束 - 如何捕捉到这个?)
                  Xcode iOS organizer submit to app store yields quot;The archive is invalidquot; error(Xcode iOS 管理器提交到应用商店产生“存档无效;错误)
                  MFMessageComposeViewController alloc returns nil(MFMessageComposeViewController alloc 返回 nil)
                  How to add and get the values from .plist in iOS(如何在 iOS 中从 .plist 添加和获取值)
                    <legend id='13qbu'><style id='13qbu'><dir id='13qbu'><q id='13qbu'></q></dir></style></legend>
                        <bdo id='13qbu'></bdo><ul id='13qbu'></ul>

                        <small id='13qbu'></small><noframes id='13qbu'>

                          <tfoot id='13qbu'></tfoot>

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