“NSInternalInconsistencyException”,原因:“entityForName:无法找到实体名称的 NSManagedObjectModel”

发布于 2024-10-03 12:56:53 字数 601 浏览 7 评论 0原文

我有一个基于窗口的应用程序,其中集成了选项卡栏和导航栏。导航栏上有一个可打开表格视图的自定义按钮。

单击表格的单元格时,我想打开一个新的表格视图控制器。但是,一旦我单击第一个表的单元格,我就会收到一个异常,

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

高冷爸爸 2024-10-10 12:56:53

我曾经遇到过同样的问题,首先检查您的 AppDelegate.m 类是否创建了 ManagedObjectContext

如果创建了它,请检查它是否将其作为参数传递
像这样的东西,

 MasterViewController *controller = (MasterViewController *)masterNavigationController.topViewController;
    controller.managedObjectContext = self.managedObjectContext;

如果这对你的主视图来说是正确的,只需确保你通过你的视图传递它,这样的东西

self.detailViewController.managedObjectContext = self.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

 MasterViewController *controller = (MasterViewController *)masterNavigationController.topViewController;
    controller.managedObjectContext = self.managedObjectContext;

if that is correct for you main view just be sure that you are passing it through your views something like this

self.detailViewController.managedObjectContext = self.managedObjectContext;

well at least that works for me =)

风吹雪碎 2024-10-10 12:56:53

此问题的最常见原因是实体名称拼写错误或大小写错误。检查代码和数据模型编辑器中的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文