Coredata crash while fetching

我与影子孤独终老i 提交于 2019-12-04 04:11:32

Accessing (Write or Read) a Managed Object on any thread other than the Managed Object Context Queue causes undefined behaviour & leads to random weird crashes.
It looks like your Managed Object Context was created with NSPrivateQueueConcurrencyType & your performing fetch on the Main Queue. This is the source of the weird crash.
You can either initialize MOC with NSMainQueueConcurrencyType or nest all your fetchRequests inside [MOC performBlock:{...}]

Core-date managedObjectContext and managedObjects are not thread-safe - neither for writing or for reading. If you ever violate this rule core-date can crash at any time - not necessarily where/when the violation occurred. So even if you are on the main thread and accessing a context designed for the main thread it can still crash if you did something wrong somewhere else in your app.

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