本文介绍了persistentStoreManagedObjectContext vs mainQueueManagedObjectContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚上好!

因此,在将数据保存到Core Data中时,我一直在理解到底是怎么回事。首先,一个简单的问题:

So I've been having some trouble understanding what the hell is going on while saving my data in Core Data. First of all, a quick question:

1)我什么时候应该使用persistentStoreManagedObjectContext?何时应该使用mainQueueManagedObjectContext ?!现在,我总是使用persistentManagedObjectContext,但我可以看到一个RestKit调用getObjectsPath,该对象将拥有mainQueueObjectContext。为什么?!

1) When should I be using the persistentStoreManagedObjectContext and when should I be using the mainQueueManagedObjectContext?! Right now, I always use the persistentManagedObjectContext, but I can see that a RestKit call "getObjectsPath", the object will have the mainQueueObjectContext. Why is that?!

谢谢!

推荐答案

persistentStoreManagedObjectContext 可用于填充其他另一个NSManagedObjectContext(例如,用于后台线程)。

persistentStoreManagedObjectContext could be used to populate other another NSManagedObjectContext (e.g. for a background thread).

因此,除非您在访问对象时不离开主线程,否则请使用 mainQueueManagedObjectContext 并且您正在使用安全的网站。

So unless your not leaving the main thread when accessing the object, use the mainQueueManagedObjectContext and you're on the safe site.

这篇关于persistentStoreManagedObjectContext vs mainQueueManagedObjectContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 14:28