• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Custom Entity Migration Policy - solved ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom Entity Migration Policy - solved ?


  • Subject: Re: Custom Entity Migration Policy - solved ?
  • From: Andrew Kimpton <email@hidden>
  • Date: Sun, 2 Dec 2007 21:29:22 -0500


On Dec 2, 2007, at 5:15 PM, Andrew Kimpton wrote:

I've specified a custom NSEntityMigrationPolicy subclass to migration one of my entities.

When createRelationshipsForDestinationInstance... is called I retrieve the array of relationship expressions I created in the mapping model using Xcode.

I'd like to simple execute all but one of these expressions - I only need to customize the relationship mapping for one of the relationships, the others are adequately handled using the details from the mapping model.

I've tried a number of different ways to evalute the expression - but all seem to give an error :

Can't get value for 'manager' in bindings {
}

in the debugger console when I call :

[migrationExpression expressionValueWithObject:self context:context];


A little more trial and error and I came up with :

NSExpression *migrationExpression = [aPropertyMapping valueExpression];
NSArray *sourceInstancesArray = [manager sourceInstancesForEntityMappingNamed:[mapping name] destinationInstances:[NSArray arrayWithObject:dInstance]];
NSManagedObject *source = nil;
if ([sourceInstancesArray count] > 0)
source = [sourceInstancesArray objectAtIndex:0];
NSMutableDictionary *context = [[[NSMutableDictionary alloc] init] autorelease];
[context setValue:manager forKey:@"manager"];
[context setValue:source forKey:@"source"];
id expressionResult = [migrationExpression expressionValueWithObject:nil context:context];


Which seems to work fine - but I'm not convinced it's correct ? The documentation seems sparse so I might be missing something - anyone else care to comment ? In particular is it at all possible to get multiple entries in the sourceInstancesArray if only one destinationInstance is specified ? Or am I guaranteed to only get a one for one result ?

Andrew 8-)


_______________________________________________

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


References: 
 >Custom Entity Migration Policy (From: Andrew Kimpton <email@hidden>)

  • Prev by Date: default write ... for turning on GUI scripting?
  • Next by Date: Re: default write ... for turning on GUI scripting?
  • Previous by thread: Custom Entity Migration Policy
  • Next by thread: Re: Custom Entity Migration Policy
  • Index(es):
    • Date
    • Thread