'+entityForName: nil is not a legal NSPersistentStoreCoordinator for searching for entity name

给你一囗甜甜゛ 提交于 2019-12-07 23:33:07

问题


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


回答1:


self.managedObjectModelName is same as your data model name?

I guess some where here is problem in names itself.



来源:https://stackoverflow.com/questions/26890278/entityforname-nil-is-not-a-legal-nspersistentstorecoordinator-for-searching-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!