私は手動移行に取り組んでおり、主にこのstackoverflowの回答をガイドとして使用しています: https ://stackoverflow.com/a/8155531/5416
移行する必要のある3つの個別のエンティティがあります。それぞれの1つのプロパティのみが変更され、整数から文字列に変更されます。一部のエンティティは正常に処理されているようで、例外はスローされていませんが、プロセスは完了していません。それはすべて本質的にまったく同じであるエラーの束をリストします:
Error Domain = NSCocoaErrorDomain Code = 1570 \ "操作を完了できませんでした\U2019。(Cocoaエラー1570)\" UserInfo = 0x2a4c2790 {NSValidationErrorObject = NSManagedObject_CCRecipeIngredient_2:、NSValidationErrorKey = name、NSLocalizedDescription=操作を完了できませんでした\U2019。(ココアエラー1570。)}
これをトラブルシューティングするための最善の方法はありますか?それが役立つ場合は、私が使用している移行ポリシーは次のとおりです。
- (BOOL)createDestinationInstancesForSourceInstance:(NSManagedObject *)aSource
entityMapping:(NSEntityMapping *)mapping
manager:(NSMigrationManager *)migrationManager
error:(NSError **)error {
NSString *attributeName = @"foodId";
NSEntityDescription *aSourceEntityDescription = [aSource entity];
NSString *aSourceName = [aSourceEntityDescription valueForKey:@"name"];
NSManagedObjectContext *destinationMOC = [migrationManager destinationContext];
NSManagedObject *destEntity;
NSString *destEntityName = [mapping destinationEntityName];
if ([aSourceName isEqualToString:@"CCFood"] || [aSourceName isEqualToString:@"CCFoodLogEntry"] || [aSourceName isEqualToString:@"CCRecipeIngredient"] )
{
destEntity = [NSEntityDescription
insertNewObjectForEntityForName:destEntityName
inManagedObjectContext:destinationMOC];
// attribute foodid
NSNumber *sourceFoodID = [aSource valueForKey:attributeName];
if (!sourceFoodID)
{
[destEntity setValue:@"0" forKey:attributeName];
}
else
{
NSInteger sourceFoodIDInteger = [sourceFoodID intValue];
NSString *sourceFoodIDString = [NSString stringWithFormat:@"%i", sourceFoodIDInteger];
[destEntity setValue:sourceFoodIDString forKey:attributeName];
}
[migrationManager associateSourceInstance:aSource
withDestinationInstance:destEntity
forEntityMapping:mapping];
return YES;
} else
{
// don't remap any other entities
return NO;
}
}