Basically my code is probably more complex than required for what you want to do. Rather than just allowing straight duplication my code also allows importing of objects from other files, including merging objects from another file over ones in the current file, which adds complexity.
My code also has a master duplication list, which is stored in MyDocument.m which sees which files have already been duplicated, which is due to the fact that my model has loops, e.g. Character<==>Feat<==>Spell Class<==>Character, so that would cause infinite loops otherwise.
I have updated the documentation for ERNSManagedObjectExtended so it should be more obvious what does what. There is some DOxygen documentation in the html folder in the full source which is available
here.
Most stuff is in ERNSManagedObjectExtended but if you have loops in your model graph you'll also need to look at MyDocument.m specifically the methods:
Code:
-(int)indexInOrigObjectsOfTheObject:(NSManagedObject *)obj;
-(NSManagedObject *)origObjectAtIndex:(int)index;
-(NSManagedObject *)newObjectAtIndex:(int)index;
-(void)addOrigObject:(NSManagedObject *)obj;
-(void)addNewObject:(NSManagedObject *)obj;
And you also need to remember to initialise the arrays
origObjectsCopied and
newObjectsCopied which I do at initialisation of MyDocument.
If you want to merge objects and check whether two objects are the same you'll also need to look at some methods in MenuController, but they have a subtle bug which I'll be fixing (it is mentioned in the comments in ERNSManagedObjectExtended, but I'm too busy to fix it today)