Refactoring existing Core Data entity classes?


Steve Christensen
 

I have inherited some code where Core Data entity classes look something like this:

@interface Entity1 : NSManagedObject
Something* common1;
Something* common2;
Something* common3;

SomethingElse* entity1Specific;
...
@end

@interface Entity2 : NSManagedObject
Something* common1;
Something* common2;
Something* common3;

SomethingElse* entity2Specific;
...
@end


I’d like to refactor the classes into:

@interface Common : NSManagedObject
Something* common1;
Something* common2;
Something* common3;
@end

@interface Entity1 : Common
SomethingElse* entity1Specific;
...
@end

@interface Entity2 : Common
SomethingElse* entity2Specific;
...
@end


Is this possible using just a new model version and/or mapping model, or does it require something more involved?

Thanks,
Steve

Join cocoa@apple-dev.groups.io to automatically receive all group messages.