1

I have an entity that originally started with a date attribute. I have now added a attribute that is a string that I want to hold the date, in addition to keeping the original field. I've made a mapping model, but I'm not sure what to put into "value expression" to get the new string field filled with data from the date field in the format "2010-10-25" during migration.

Any help would be appreciated.

Also I need it to be a real attribute not a transient because I want to sort on it. I didn't realize you couldn't sort on transient attribute until too late.

westsider
  • 4,967
  • 5
  • 36
  • 51
agilityvision
  • 7,901
  • 2
  • 29
  • 28
  • You want to sort on the date string representation, not the date itself? – Terry Wilcox Mar 17 '10 at 14:49
  • I just need the new text field filled in during migration from the existing date field. The app already uses it, I just need to hook up people with older version of the app to migrate their existing core data. – agilityvision Mar 17 '10 at 17:02

1 Answers1

2

Translating the property from a date to a string is going to require that you build your own NSEntityMigrationPolicy for that migration and override the -createDestinationInstancesForSourceInstance: entityMapping: manager: error: method to handle the translation.

This should be very straight forward code since you are only going to be manipulating a couple of properties and the entity mapping is still one to one.

Marcus S. Zarra
  • 46,571
  • 9
  • 101
  • 182