Skip navigation.
 
ml[Leopard] Core Date migration lacks custom object classes
FROM : Pierre Bernard
DATE : Tue Nov 06 15:23:38 2007

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

Related mailsAuthorDate
ml[Leopard] Core Date migration lacks custom object classes Pierre Bernard Nov 6, 15:23
mlRe: [Leopard] Core Date migration lacks custom object classes Adam Swift Nov 6, 20:39
mlRe: [Leopard] Core Date migration lacks custom object classes Pierre Bernard Nov 6, 21:09
mlRe: [Leopard] Core Date migration lacks custom object classes Adam Swift Nov 7, 00:41