[英]Adding CoreData to existing Project
I am trying to add CoreData to an existing project and there is strange error... 我正在尝试将CoreData添加到现有项目中,并且存在奇怪的错误......
I get the error: 我收到错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Cannot create an NSPersistentStoreCoordinator with a nil model' 由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因是:'无法使用nil模型创建NSPersistentStoreCoordinator'
in RootView there is a warning in: 在RootView中有一个警告:
- (NSFetchedResultsController *)fetchedResultsController;
in line: 排队:
_fetchedResultsController.delegate = self;
and it says: 它说:
warning: class 'RootViewController' does not implement the 'NSFetchedResultsControllerDelegate' protocol 警告:类'RootViewController'没有实现'NSFetchedResultsControllerDelegate'协议
any ideas? 有任何想法吗?
argh! 哎呀!
sorry for even asking, I just missed that I changed the name of .xcdatamodel 对不起甚至问,我只是错过了我更改了.xcdatamodel的名字
I needed just to change the name in managedObjectModel and persistentStoreCoordinator 我只需要在managedObjectModel和persistentStoreCoordinator中更改名称
hope it'll help someone anyway. 希望无论如何它会帮助别人。
I was getting the same exception. 我得到了同样的例外。
My issue was that I had added the .xcdatamodeld
file in the root directory of the project (with siblings Frameworks
and Products
) instead of in the folder named after the project (with siblings Supporting Files
, AppDelegate.h
, etc.) 我的问题是我在项目的根目录中添加了.xcdatamodeld
文件(与兄弟Frameworks
和Products
)而不是在项目后命名的文件夹中(与兄弟姐妹Supporting Files
, AppDelegate.h
等)
I tracked it down to this line: NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Foo" withExtension:@"momd"];
我跟踪到这一行: NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"Foo" withExtension:@"momd"];
In this method: - (NSManagedObjectModel *)managedObjectModel
在此方法中: - (NSManagedObjectModel *)managedObjectModel
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.