我遵循这个漂亮的教程http://mipostel.com/index.php/home/70-core-data-migration-standard-migration-part-2来做我的核心数据迁移。映射模型为NULL - 核心数据迁移
出于某种奇怪的原因,我总是得到NULL在mappingModel在这些行:
NSMappingModel *mappingModel = [NSMappingModel mappingModelFromBundles:nil
forSourceModel:sourceModel
destinationModel:destinationModel];
(在链接的代码行191)
我试图创建模型的一个非常简单的衍生版本,我重新创建了一次mappingModel 1000次,确保映射模型文件位于项目目录中 - 但此调用始终返回NULL。
有人有什么想法吗?
ps我只是想知道设置迁移选项被称为AFTER使用映射模型。
NSURL *storeUrl = [NSURL fileURLWithPath:storePath];
NSError *error;
NSDictionary *pscOptions = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:NO], NSInferMappingModelAutomaticallyOption,
nil];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:storeUrl
options:pscOptions
error:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
(线123 ...)
反正
为什么不能映射模型可以找到?
pss忍不住回头:-)这个核心数据迁移的东西与做简单的SQL数据库迁移相比太复杂和困难 - 浪费太多时间。
所以一个大感谢提前!
事实上,因为它证明了教程似乎是错误的 - 所以尝试找到另一个在浪费尽可能多的时间之前,我做了.... :-() – user387184 2012-07-17 09:25:29