iPhone:core data error:+ entityForName:找不到实体名称为'Name'的NSManagedObjectModel, [英] iPhone: core data error: +entityForName: could not locate an NSManagedObjectModel for entity name 'Name'

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

问题描述


可能重复:

insertNewObjectForEntityForName: / a>

Possible Duplicate:
insertNewObjectForEntityForName:

查看标题^

代码导致:

NSManagedObjectContext *context = [fetchedResultsController managedObjectContext];

    Name *name = (Name *)[NSEntityDescription insertNewObjectForEntityForName:@"Name" inManagedObjectContext:context];

    Feature *feature = (Features *)[NSEntityDescription insertNewObjectForEntityForName:@"thing" inManagedObjectContext:context];
    [feature setName:app];  
    [name addFeaturesObject:feature];

app是之前定义的NSString。

app is an NSString defined earlier.

我尝试的东西:

in viewDidLoad:

in viewDidLoad:

 if (managedObjectContext == nil)
{ 
    managedObjectContext = [(IsidoreAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
}


推荐答案

未设置,实体名称显然不适用于nil上下文。

Your managed object context is probably not set and the entity "Name" is obviously not valid for a nil context.

在viewDidLoad中,您正在使用应用代理为视图控制器设置managedObjectContext实例变量,这是很好的,但是您的问题代码正在使用受管对象上下文从获取的结果控制器。已经设置了吗?

In viewDidLoad, you are setting the "managedObjectContext" instance variable for your view controller by using the app delegate which is fine, but then your problem code is using the managed object context from the fetched results controller. Has that been setup yet?

此外,请查看此答案核心数据和UITabBar控制器 - 帮助?!

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

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