私は、MagicalRecordを使用してCore Dataの軽量移行をセットアップしようとすると、レンガの壁にぶつかってきました。 GoogleとSOを使用して、この件に関するすべての投稿を見てきました。 persistentStoreCoordinatorがどのように機能し、どのような設定を行うかについても理解しています。MagicalRecordを使用してCore Data Lightweightマイグレーションを設定するにはどうすればよいですか?
ここに私のコードだ:
AppDeligate.h
NSPersistentStoreCoordinator *persistentStoreCoordinator;
AppDelegate.m
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
if (persistentStoreCoordinator != nil) {
return persistentStoreCoordinator;
}
NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"saori.sqlite"]];
// handle db upgrade
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
NSError *error = nil;
persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [self managedObjectModel]];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) {
// Handle error
}
return persistentStoreCoordinator;
}
私は、WHIを次のエラーを取得しています私は理解しています。いいえ「applicationDocumentsDirectory」
「AppDelegate」の目に見える@interfaceはセレクタを宣言しないと
:私が知らないことは、これらのオブジェクトは、(私は私のアプリで見て、何も見つからなかった)しているところであります
: 'AppDelegate' の目に見える@interfaceは、セレクタ 'managedObjectModel'
私はすでに作成している店舗を宣言する10
ほとんどの場合、私が見たコードのすべてが似ているとは限りません。 MagicalRecordが私のためにこれを処理するかどうかはわかりません。なぜなら、MRを使ってこれを行う方法を示すドキュメントを見つけることができないからです。私の質問は:私はこの仕事をするために何をしなければならないのですか? MagicalRecordの
最後のスクリーンショットでは、新しいモデルがまだアクティブにされていないため、古いモデルが引き続き使用されます。 –