ios – CoreData中NSConfinementConcurrencyType的用法是什么?

前端之家收集整理的这篇文章主要介绍了ios – CoreData中NSConfinementConcurrencyType的用法是什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我对NSManagedObjectContext的类型有一些疑问.让我们看一下苹果关于NSConfinementConcurrencyType的文档:

Confinement (NSConfinementConcurrencyType)

For backwards compatibility,this is the default. You promise that context will not be used by any thread other than the one on which you created it. In general,to make the behavior explicit you’re encouraged to use one of the other types instead.

You can only use this concurrency type if the managed object context’s parent store is a persistent store coordinator.

我无法理解为什么这种类型只能由父存储是持久存储协调器的对象上下文使用.例如,我创建一个NSManagedObjectContext使用这种类型,并将它的父存储设置为另一个上下文,是否会产生一些错误.

解决方法

实际的答案是从iOS 9开始不推荐使用NSConfinementConcurrencyType,因此您根本不应该使用它,此时可以或不可以使用它的详细信息是无关紧要的.

我怀疑,更深层次的答案是文档中“向后兼容性……”的一个方面.队列限制与嵌套上下文同时添加.可能该计划总是最终弃用NSConfinementConcurrencyType,因此没有努力更新它以使用嵌套上下文.只有Core Data团队确切知道,但是可能存在与使用嵌套上下文的限制并发相关的一些重要错误,但修复它们并不是优先考虑的问题.

猜你在找的iOS相关文章