persistentStoreManagedObjectContext vs mainQueueManagedObjectContext

北城以北 提交于 2019-12-07 01:15:26

问题


Good evening!

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) 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?!

Thanks!


回答1:


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

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



来源:https://stackoverflow.com/questions/15457290/persistentstoremanagedobjectcontext-vs-mainqueuemanagedobjectcontext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!