'+ entityForName:nil不是用于搜索实体名称的合法NSPersistentStoreCoordinator [英] '+entityForName: nil is not a legal NSPersistentStoreCoordinator for searching for entity name
问题描述
在使用_managedObjectModel时,稍后在程序中获取异常。以下是初始化代码。
NSURL * modelURL = [[NSBundle mainBundle] URLForResource:self.managedObjectModelName withExtension:@momd];
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
问题是_managedObjectModel指向一个垃圾内存位置。
在分析GPR和汇编代码之后,我发现ManagedObjectModel被正确初始化,但是当模式的内容被加载到其中时 - 对象指针在对象之前的开始指向随机位置,或者在对象之间的某处对象的分配内存。
如果我尝试使用这样的东西来访问底层内容:[_managedObjectModel - > _ entities allKeys],我得到模式中的所有键。
有没有人遇到这样的问题?
这可能类似于 https://github.com/typhoon-framework/Typhoon/issues/138
self.managedObjectModelName与数据模型名称相同?
我猜这里有一些问题在名称本身。 / p>
Getting the exception later in the program when _managedObjectModel is being used. Below is initialiser code.
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:self.managedObjectModelName withExtension:@"momd"];
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
The problem is that _managedObjectModel is pointing to a garbage memory location. After analysing GPR and assembly code i found that the ManagedObjectModel was being initialised properly but, when the content from schema is being loaded into it - the object pointer starts pointing at random locations way before the object is, or somewhere in between the object's allocated memory.
If i try to access underlying content using something like this : [_managedObjectModel->_entities allKeys], i do get all the keys in schema.
Has anyone ever faced such issues ?
This is probably something similar to https://github.com/typhoon-framework/Typhoon/issues/138
self.managedObjectModelName is same as your data model name?
I guess some where here is problem in names itself.
这篇关于'+ entityForName:nil不是用于搜索实体名称的合法NSPersistentStoreCoordinator的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!