insertNewObjectForEntityForName:inManagedObjectContext:返回NSNumber错误?
我相对精通CoreData,并且几年来一直使用它很少或没有困难。对于我的生活,我无法弄清楚为什么
I'm relatively well versed in CoreData and have been using it for several years with little or no difficulty. For the life of me, I can't figure out why
insertNewObjectForEntityForName:inManagedObjectContext:
突然返回某种奇怪的NSNumber实例。 GDB说返回的对象是NSManagedObject的正确自定义子类,但是当我去打印NSManagedObject本身的描述时,我收到以下错误:
is all of a sudden returning some sort of strange instance of NSNumber. GDB says the returned object is of the correct custom subclass of NSManagedObject, but when I go to print a description of the NSManagedObject itself, I get the following error:
*** -[NSCFNumber objectID]: unrecognized selector sent to instance 0x3f26f50
更奇怪的是,我能够使用setValue设置一些关系和属性:forKey:一切都很好。但是当我尝试设置一个特定关系时,我收到此错误:
What's even stranger, is that I'm able to set some relationships and attributes using setValue:forKey: and all is good. But when I try to set one specific relationship, I get this error:
*** -[NSCFNumber entity]: unrecognized selector sent to instance 0x3f26f50
我已尝试从干净的所有目标到重启mac和iPhone,甚至编辑模型,以便所讨论的关系是一个而不是多个。无论我做什么,都会出现同样的问题。有没有人见过这样的事情?
I've tried everything from clean all targets, to restarting both mac and iPhone, even editing the model so that the relationship in question is to-one instead of to-many. No matter what I do, the same problem appears. Has anyone ever seen anything like this before?
我遇到了同样的问题:我添加了一个名为isDatabase的方法(返回BOOL)到我的Database实体的父实体,该实体具有名为database的关系。将isDatabase重命名为isOfTypeDatabase修复了该问题。所以请继续查看父实体!
I had the very same issue: I had added a method called "isDatabase" (returning a BOOL) to the parent entity of my Database entity, which had a relationship named "database". Renaming "isDatabase" to "isOfTypeDatabase" fixed the issue. So keep also looking in parent entities!