I created a custom migration policy for the abstract class by subclassing NSEntityMigrationPolicy. This gave me a way to look at what was happening. The abstract class, HMPart had a one-to-many relationship with a concrete class, HMInput. Call one of the concrete subclasses of HMPart HMThing. When the migration process came to createRelationshipsForDestinationInstance for an instance of HMInput, the to-one relationship to the instance of HMThing had already been correctly instantiated; that is, there was an instance of HMThing on the far side of the relationship. But when createRelationshipsForDestinationInstance was exectued, the HMThing instance was tossed out and replaced by nil, because the migrator did not know how to create an instance of HMPart. So the migrator did the right thing, and then screwed it up.
This observation led me to write the following, which is called by the migrator with the child instance, e.g. an instance of HMInput, as "dInstance". The method merely saves the parent object, calls the super method (which destroys the parent object), and finally restores the parent. You might think that you could dispense with the super method, since you are just undoing what the super method did. But it seems that the super method does other things that actually are necessary.
- (BOOL)createRelationshipsForDestinationInstance:(NSManagedObject *)dInstance entityMapping:(NSEntityMapping *)mapping manager: (NSMigrationManager *)manager
error:(NSError **)error { id part = [dInstance valueForKey:@"part"];BOOL result = [super createRelationshipsForDestinationInstance:dInstance
entityMapping:mapping manager:manager error:error]; [dInstance setValue:part forKey:@"part"]; return result; } This successfully worked around the problem. -- Timothy Larkin Abstract Tools Caroline, NY
PGP.sig
Description: This is a digitally signed message part
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]