このすばらしいチュートリアル http://mipostel.com/index.php/home/70-core-data-migration-standard-migration-part-2に従って、コア データの移行を行います。
いくつかの奇妙な理由で、これらの行の mappingModel で常に NULL を取得します。
NSMappingModel *mappingModel = [NSMappingModel mappingModelFromBundles:nil
forSourceModel:sourceModel
destinationModel:destinationModel];
(リンクされたコードの 191 行目)
モデルの非常に単純な派生バージョンを作成しようとしました。mappingModel を 1000 回再作成し、マッピング モデル ファイルがプロジェクト ディレクトリにあることを確認しましたが、この呼び出しは常に NULL を返します。
ここで何が間違っているのか誰にも分かりますか?
ps移行オプションの設定は、マッピングモデルが使用された後に呼び出されることに疑問に思っていました。
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 DB の移行に比べて非常に複雑で困難であり、非常に多くの時間を無駄にしています。
事前に大きな感謝を!