reason = "The model used to open the store is incompatible with the one used to create the store";
You must have changed the model at some point. Remove the app from the device/simulator and then reload it. All should be fine after that.
从模拟器中删除这个app重新加载一下就好了。
另外,如果报Cannot create an NSPersistentStoreCoordinator with a nil modeld错误,说明app没有和库文件链接,所以需要修改delegate.m中的代码,例如我的文件名是Lines.xcdatamodeld:
- (NSManagedObjectModel *)managedObjectModel
{
if (__managedObjectModel !=nil) {
return __managedObjectModel;
}
NSURL *modelURL = [[NSBundlemainBundle] URLForResource:@"Lines"withExtension:@"momd"];
__managedObjectModel = [[NSManagedObjectModelalloc] initWithContentsOfURL:modelURL];
return __managedObjectModel;