Saturday, 17 August 2013

Core data: to-many relationship removing target object when removing from relationship

Core data: to-many relationship removing target object when removing from
relationship

Image I have 2 Core Data entities, namely EntityA and EntityB.
EntityA has many EntityB's and EntityB belongs to one EntityA, i.e.:
EntityA ----- (entities) ->> EntityB
EntityB ----- (entity) ----> EntityA
Now image I have a EntityA *entityA which already has some entities.
Now I do the following:
entityA.entities = @[/* some new entityB's */];
Now the "old" entityB's will have a entity of nil and are thus "dangling".
I want to remove these entityB's, is there an option to do so? Of course I
could do it manually, but I feel like Core Data has some method of doing
this automatically.

No comments:

Post a Comment