Illegal relationship between objects in different contexts: but I only have one context?

眉间皱痕 提交于 2019-12-01 04:50:26

How are you creating your Entities? If you are creating an entity without a NSManagedObjectContext it would produce the same error.

Update

From the look of your code I am guessing that what you are getting back out of the picker is not what you are expecting or unnecessarily casting to.

I would put a breakpoint on objc_throw_exception and duplicate the crash in the debugger. Once you do that then inspect the objects and I expect you will find that what you are getting out of the picker is not a NSManagedObject but something else.

I've seen weird errors like this are often due to a stale data store. Have you tried completely removing the app from the sim or device (e.g. tap-hold delete)? Do a clean build, then build and run.

Interestingly enough, this error can be caused by the wrong NSManaged Object inserted into another NSManaged object.

Something like this: I.E Orange A Apple B //many to one relationship

A.b = [NSOrderedset setwithObjects Orange,nil];

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