两个持久存储一个管理对象上下文 - 可能? [英] Two persistent stores for one managed object context - possible?

查看:133
本文介绍了两个持久存储一个管理对象上下文 - 可能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个相当复杂的数据模型,大约有10个实体。有些需要存储到磁盘,其他只需要在应用程序运行时在内存中可用。是否有可能使用两个持久存储为同一个托管对象上下文,或者应该相应地分离我的数据模型?

I have a fairly complex data model with approximately 10 entities. Some need to be stored to disk and others just need to be available in memory when the application is running. Is it possible to achieve this using two persistent stores for the same managed object context, or should I separate my data models accordingly?

推荐答案

是的,您的NSManagedObjectContext使用NSPersistentStoreCoordinator来确定特定模型应该使用哪个商店。通过设置托管对象上下文的持久存储协调器,您可以定义使用不同类型的多个持久存储的自定义映射。

Yes, your NSManagedObjectContext uses a NSPersistentStoreCoordinator to determine which store a particular model should use. By setting the persistent store coordinator of your managed object context you can define a custom mapping which uses multiple persistent stores of different types.

http://developer.apple。 com / library / ios / documentation / Cocoa / Conceptual / CoreData / Articles / cdBasics.html#// apple_ref / doc / uid / TP40001650-SW4

这篇关于两个持久存储一个管理对象上下文 - 可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆