+entityForName:无法找到名为“Dogs”的实体;在这个模型中。
关于核心数据模型的一个小问题。
这就是我发布的原因:+entityForName:无法在此模型中找到名为“Dogs”的实体。
我想要做什么: 我想创建一个应用程序,它将读取/写入有关具有 2 个实体 Cats
和 Dogs
的动物的核心数据详细信息。
- 为此,我创建了一个基于窗口的项目,并选中了“使用核心数据”。 - 然后,我创建视图,然后单击“animals.xcdatamodeld”文件来创建第一个名为 Cats
的实体。我添加属性,生成类“cats.h”和“cats.m”。 - 我写下在这个实体上读写的代码 =>没问题,一切正常。
此时,我手动删除文件“animals.xcdatamodeld”犯了一个错误...我用相同的名称重新创建它,并添加一个新实体
Dogs
及其属性,并生成关联的 和这就是问题所在,当我构建并运行错误消息时出现:
+entityForName:无法在此模型中找到名为“Dogs”的实体。
仅供参考,<上的读/写code>Cats 仍然可以。
我不知道为什么会出现此错误...我没有更改应用程序委托上的任何内容。我在网上找到与该问题相关的信息很少。 我发现的唯一一件事是,模型更新时可能需要进行版本控制=>有人可以解释一下吗? 无论如何,当我添加新实体时,模型似乎没有更新......
谢谢。
A little question regarding Core data models.
Here is why I'm posting : +entityForName: could not locate an entity named 'Dogs' in this model.
What I wanna do :
I wanna create an app that will read/write in core data details about animals with 2 entities Cats
and Dogs
.
-For that I create a window-based project with "use core data" checked.
-Then I create my views, and click on "animals.xcdatamodeld" file to create a first entity called Cats
. I add the attributes, generate the class "cats.h" and "cats.m".
- I write down the code to read and write on this entity => No problem everything works well.
At this point I made a mistake by deleting the file "animals.xcdatamodeld" manually... I recreate it with the same name and add a new entity
Dogs
with its attributes and generate the associated class.That's where the problem is, when I build and run the error message comes :
+entityForName: could not locate an entity named 'Dogs' in this model.
FYI, the read/write onCats
is still ok.
I have no idea why this error appears... I did not change anything on the App Delegate. I found very little information online related to that issue.
This only thing I found was that maybe the model needs to be versioned when updated => Can someone explain that a lil bit please ?
Anyway the model does not seem to have been updated when I added the new entity...
Thx.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,正如预期的那样,这个错误是由于一个愚蠢的错误造成的......
删除的 xcdatamodeld 文件被替换为具有不同拼写的新文件...
现在一切都很好...
Ok as expected somehow, this error was due to a stupid mistake...
The deleted xcdatamodeld file was replaced by a new one with a different spelling...
Now everything's fine...