Custom Core Data mapping: Inserting a new entity in between an existing relationship

StackOverflow https://stackoverflow.com/questions/23579693

  •  19-07-2023
  •  | 
  •  

Вопрос

An example of my data model version 1 looks like this: enter image description here

The cake is eaten by some guests.

In data model version 2 not every guest will eat the same amount of pieces. I want to assign each guest an individual number of pieces: enter image description here

(numberOfPieces could be set to a default of 1 pieces.)

How can that be accomplished? I've implemented a custom mapping model and set a custom policy for the mapping CakeToCake. However, I'm unsure what to do. Does my policy have to implement createRelationshipsForDestinationInstance:entityMapping:manager:error: where I would manually create the PieceOfCake object?

Это было полезно?

Решение

I think I did the right thing and finally created PieceOfCake in createRelationshipsForDestinationInstance:entityMapping:manager:error:. It works well.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top