'NSInternalInconsistencyException',原因:'+ entityForName:找不到实体名称的NSManagedObjectModel [英] 'NSInternalInconsistencyException', reason: '+entityForName: could not locate an NSManagedObjectModel for entity name

查看:73
本文介绍了'NSInternalInconsistencyException',原因:'+ entityForName:找不到实体名称的NSManagedObjectModel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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''

检查 AddForm 在正确的位置。

我已经尝试了上面和其他线程上给出的所有解决方案,但是仍然卡住。我希望有人能帮助我。

I have tried all the solutions given above and on other thread, but still stuck. I hope someone can help me.

流程是这样的

ListButton(单击可打开列表)视图)->打开一个表视图->(单击一个单元格应打开一个新的表视图Controller并从核心数据中获取数据)

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....

请帮助

预先感谢

推荐答案

I如果托管对象上下文为,我曾经遇到过同样的问题,首先请检查AppDelegate.m类已创建

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;

至少对我有用=)

这篇关于'NSInternalInconsistencyException',原因:'+ entityForName:找不到实体名称的NSManagedObjectModel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆