0

アプリのバージョンアップをしたいのですが、新しいバージョンではコアデータに2つの新しい属性を追加し、古いバージョンから新しいバージョンにデータを移行したいです。私のステップ:

  1. .xcdatamodeld ファイルを選択,エディタ -> モデル バージョンの追加
  2. [デザイン] > [データ モデル] > [現在のバージョンを設定]。
  3. オプションの変更

     NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:  
                                        [NSNumber numberWithBool:YES],  NSMigratePersistentStoresAutomaticallyOption,  
                                        [NSNumber numberWithBool:YES],   NSInferMappingModelAutomaticallyOption, nil];  
     if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&error]) 
    

しかし、私の新しいバージョンでは、古いバージョンのデータは見つかりませんでした。それを変更する方法。

4

1 に答える 1

0

私は私の間違いを見つけました:PushNoticationModal.sqliteはPushNoticationModel.xcdatamodelという名前と同じではありません。PushNoticationModalはPushNoticationModelとは異なります。

PushNoticationModel.xcdatamodelと同じではないPushNoticationModal.sqliteという名前のsqliteを1つだけビルドする場合は、アプリも実行できます。ただし、移行をビルドする場合は、同じままにする必要があります。

于 2012-12-13T08:59:58.353 に答える