【发布时间】:2011-03-03 23:00:49
【问题描述】:
我正在尝试升级我当前的应用程序以使用抽象父实体和专门的子实体。 我创建了一个自定义 NSEntityMigrationPolicy,并在映射模型中将自定义策略设置为我的类的名称。
我正在像这样初始化我的持久存储,这应该是相当标准的:
NSError *error=nil;
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
nil];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) {
NSLog(@"Error adding persistent store : %@",[error description]);
NSAssert(error==nil,[error localizedDescription]);
}
当我运行应用程序时,我收到以下错误:
由于未捕获而终止应用 例外 'NSInternalInconsistencyException', 原因:'操作不能 完全的。 (可可错误 134140。)'
[error userInfo] 包含“reason=Can't find mapping model for migration”
我已验证数据模型的版本 1 将打开,如果我设置 NSInferMappingModelAutomaticallyOption 我会得到迁移,尽管我的实体没有正确迁移(如预期的那样)。
我已验证映射模型 (cdm) 在应用程序包中,但不知何故它拒绝找到它。 我还在自定义迁移策略中设置了断点和 NSLog() 语句,无论有没有 NSInferMappingModelAutomaticallyOption
,它都不会运行关于为什么它似乎无法找到映射模型的任何提示?
【问题讨论】:
标签: iphone objective-c xcode core-data mapping-model