Ok, that code really looks bad through email, so I'm going to give you a link to the code in much more pleasant format: http://pastie.org/888526
> > > I'm trying to create an NSMappingModel manually between two models, but it's > not working in that no data gets migrated over (I checked with an SQLite > database browser) to the new store, the tables are just empty. > > The source model has one entity Person with two attributes: name and eyeColor. > > The destination model also has only one entity Person with two attributes: > name and address. > > Thus, name should get transferred over, eyeColor get deleted, and address > added as a new attribute. > > Given this information, what is wrong with the following code to create the > mapping model for this? > > NSMutableArray *attributeMappings = [[NSMutableArray alloc] init]; > NSPropertyMapping *propertyMapping = [[NSPropertyMapping alloc] init]; > [propertyMapping setName:@"name"]; NSString *str = [NSString > stringWithFormat:@"%[email protected]",NSMigrationSourceObjectKey]; > //i also tried "expressionForKeyPath" but it didn't work: > [propertyMapping setValueExpression:[NSExpression > expressionForConstantValue:str]]; > [attributeMappings addObject:propertyMapping]; > propertyMapping = [[NSPropertyMapping alloc] init]; > [propertyMapping setName:@"address"]; > [propertyMapping setValueExpression:nil]; > [attributeMappings addObject:propertyMapping]; > NSEntityMapping *entityMapping = [[NSEntityMapping alloc] init]; > [entityMapping setSourceEntityName:@"Person"]; > [entityMapping setDestinationEntityName:@"Person"]; > [entityMapping setName:@"PersonToPerson"]; > [entityMapping setMappingType:NSTransformEntityMappingType]; > [entityMapping setAttributeMappings:attributeMappings]; > NSMutableArray *entityMappings = [[NSMutableArray alloc] init]; > [entityMappings addObject:entityMapping]; > NSMappingModel *mappingModel = [[NSMappingModel alloc] init]; > [mappingModel setEntityMappings:entityMappings]; > > > > Thanks in advance, U. > _________________________________________________________________ > Hotmail: Free, trusted and rich email service. > https://signup.live.com/signup.aspx?id=60969_______________________________________________ > > Cocoa-dev mailing list ([email protected]) > > 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: > http://lists.apple.com/mailman/options/cocoa-dev/ulaibeekam%40hotmail.com > > This email sent to [email protected] _________________________________________________________________ Hotmail: Powerful Free email with security by Microsoft. https://signup.live.com/signup.aspx?id=60969_______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
