“NSInternalInconsistencyException”,原因:“entityForName:无法找到实体名称的 NSManagedObjectModel”
我有一个基于窗口的应用程序,其中集成了选项卡栏和导航栏。导航栏上有一个可打开表格视图的自定义按钮。
单击表格的单元格时,我想打开一个新的表格视图控制器。但是,一旦我单击第一个表的单元格,我就会收到一个异常,
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'AddForm''
我已检查 AddForm
是否位于正确的位置。
我已经尝试了上面和其他线程上给出的所有解决方案,但仍然卡住了。我希望有人能帮助我。
流程类似于此
ListButton(单击时打开列表视图)->表格视图打开 -> (单击单元格应打开一个新的表视图控制器并从核心数据中获取数据)
我的根视图控制器代码位于第二个表视图控制器文件中......这是我做错了吗?我这样做是因为在此之前我不需要核心数据......
请帮忙
提前致谢
I have a window based applicaiton with tab bar and navigation bar integrated into it. On the navigation bar have a custom button which opens a table view.
On clicking on the cell of the table I want to open a new table view controller. But as soon as I click on the cell of first table I get an exception that
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name 'AddForm''
I have checked that AddForm
is in right place.
I have tried all the solutions given above and on other thread, but still stuck. I hope someone can help me.
The flow is something like this
ListButton (on click opens a list view) -> a table view opens -> (on click of a cell should open a new table view Controller and fetch data from core data)
My root view controller code is in the second table view controller file... is that what I am doing wrong? I am doing so because I don't need the core data before that....
Please help
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我曾经遇到过同样的问题,首先检查您的 AppDelegate.m 类是否创建了 ManagedObjectContext
如果创建了它,请检查它是否将其作为参数传递
像这样的东西,
如果这对你的主视图来说是正确的,只需确保你通过你的视图传递它,这样的东西
至少对我有用=)
I Used to have the same problem first of all check in your AppDelegate.m class if the managedObjectContext is created
if it is created check if it is pass it as argument
something like this
if that is correct for you main view just be sure that you are passing it through your views something like this
well at least that works for me =)
此问题的最常见原因是实体名称拼写错误或大小写错误。检查代码和数据模型编辑器中的
AddForm
拼写是否完全相同。The most common cause of this problem is misspelling the name of the entity or getting the capitalization wrong. Check that
AddForm
is spelled exactly the same in the code and the data model editor.