[Leopard] Core Date migration lacks custom object classes
[Leopard] Core Date migration lacks custom object classes
- Subject: [Leopard] Core Date migration lacks custom object classes
- From: Pierre Bernard <email@hidden>
- Date: Tue, 6 Nov 2007 15:23:38 +0100
Hi!
I just noticed that during migration, Core Data maps all entities to
the NSManagedObject class rather than using the specified custom class.
This causes me problems as my awake and validation methods are not
called and thus leave mandatory attributes with nil values.
It also seems very wrong to me that when I create and insert instances
of my custom managed object classes within my custom migration policy,
the
initWithEntity:insertIntoManagedObjectContext: returns an instance of
NSManagedObject.
One can witness the problem using a custom migration policy:
@implementation ColumnAttributeMigrationPolicy
- (BOOL)beginEntityMapping:(NSEntityMapping *)mapping manager:
(NSMigrationManager *)manager error:(NSError **)error
{
NSManagedObjectContext *sourceContext = [manager sourceContext];
NSManagedObjectContext *destinationContext = [manager
destinationContext];
NSEntityDescription *sourceEntity = [NSEntityDescription
entityForName:@"ColumnAttribute" inManagedObjectContext:sourceContext];
NSEntityDescription *destinationEntity = [NSEntityDescription
entityForName:@"ColumnAttribute"
inManagedObjectContext:destinationContext];
NSLog(@"Source class: %@", [sourceEntity managedObjectClassName]);
NSLog(@"Destination class: %@", [destinationEntity
managedObjectClassName]);
return YES;
}
@end
This prints out the following:
2007-11-06 15:17:33.872 HoudahSpot[1812:10b] Source class: (null)
2007-11-06 15:17:33.873 HoudahSpot[1812:10b] Destination class:
NSManagedObject
Best,
Pierre Bernard
Houdah Software s.à r.l.
---
Pierre Bernard
http://www.bernard-web.com/pierre
http://www.houdah.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden