Pregunta

Wondering if its possible to concatenate keyPaths to one attribute in mapping objects. Looking for something like

mapKeyPaths @"firstname", @"lastname", nil toAttribute:@"name"

Where name would then be "Bob Johnson"

** The API I am dealing with passes over a date and a startTime attribute, as 2012/02/28 and 16:12 respectively, as Strings.

It would be easier to just use startTime as "2012/02/28 16:12".

I figured I can get around this issue by leaving the date and startTime as NSDate fields, so I have tried setting up a dateFormatter per Restkits instructions. When I tried that idea, just using "HH:MM", for the startTime dateFormatter, it shoves "1970/01/01 16:12" into the startTime field.

Anyone have any suggestions, besides going through each record manually after mapping to Core Data and putting the fields in programatically?

¿Fue útil?

Solución

I don't think you can do these kind of programmatic mappings yet.

Two alternative solutions come to mind:

1) In willMapData (or something like that) you can manually modify the incoming serialization before object mapping occurs. There you can specify a format you like.

2) Save both these properties in your Core Data entity and create a third transient attribute which is calculated at runtime, and when required, by passing these two values through a NSDateFormatter.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top