Re: Is it wrong to create relationships in -createDestinationInstancesForSourceInstance:…?
Re: Is it wrong to create relationships in -createDestinationInstancesForSourceInstance:…?
- Subject: Re: Is it wrong to create relationships in -createDestinationInstancesForSourceInstance:…?
- From: Rick Mann <email@hidden>
- Date: Sat, 19 Jul 2014 13:11:04 -0700
On Jul 19, 2014, at 12:37 , Jerry Krinock <email@hidden> wrote:
>
> On 2014 Jul 18, at 15:54, Rick Mann <email@hidden> wrote:
>
>> Is it wrong to create relationships in -createDestinationInstancesForSourceInstance:…?
>
> Yes, it is wrong, according “Three Stage Migration” of the Core Data Model Versioning and Data Migration Programming Guide…
>
> https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmMigrationProcess.html#//apple_ref/doc/uid/TP40004399-CH6-SW8
Huh. Sure enough, it says, "In this stage, only attributes (not relationships) are set in the destination objects." However, I had decided that there was no good reason not to set a relationship between two new destination objects if they were both created in one -create… call, and proceeded to do it anyway. Worked fine.
Then I discovered that you don't need to do that, if you leverage all the automatic capabilities afforded by automatic migration. Simply by calling -[super create…], you can get the bulk of the work done by specifying expressions in the Mapping Model editor, and it's got a much more compact (if somewhat unwieldy) way of specifying the new relationships. Once I realized that, my actual code got a lot smaller and tidier.
--
Rick Mann
email@hidden
_______________________________________________
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