两个受管对象上下文可以共享一个持久存储协调器吗? [英] Can two managed object context share one single persistent store coordinator?

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

问题描述

示例:我有一个持久存储协调器,它使用一个持久存储。

Example: I have one persistent store coordinator which uses one single persistent store.

现在有两个受管对象上下文,并且都想使用相同的持久存储。可以只使用相同的持久存储协调器,还是我必须创建NSPersistentStoreCoordinator的两个实例?如果我不得不,我还必须创建两个NSPersistentStore实例?

Now there are two managed object contexts, and both want to use the same persistent store. Could both simply use the same persistent store coordinator, or would I have to create two instances of NSPersistentStoreCoordinator? And if I had to, then: Would I also have to create two NSPersistentStore instances?

推荐答案

iPhone上的Core Data on iPhone 文章介绍了此主题:


在任何应用程序中,您可能有多个受管对象上下文。您可能需要维护离散的受管对象集以及对这些对象的编辑;或者您可能希望使用一个上下文执行后台操作,同时允许用户与另一个上下文中的对象进行交互。

In any application, you might have multiple managed object contexts. You might want to maintain discrete sets of managed objects and edits to those objects; or you might want to perform a background operation using one context while allowing the user to interact with objects in another. Each of these would be connected to the same coordinator.

持久存储协调器设计用于处理多个上下文

A Persistent Store Coordinator is designed to handle multiple contexts

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

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