Reputation:
I have following entities in Core Data:
PBOUser
may have a lot of PBOLocation
.PBOLocation
may have a lot of PBOStatistics
. PBOStatistics
may belong to only one PBOLocation
PBOLocation
may belong to a lot of PBOUser
My relationship are described on the image below:
My problem:
I have userA
with locationA
and locationB
and locationC
I have userB
with locationA
and locationD
Now inside userA
I assign a new NSSet
with locationB
.
What happens now?
locationC
? (I really want that, because this location belongs ONLY to user being removed)locationA
? (I really do not want that, because that location belongs to other user: userB
).What should I do to achieve that result?
Upvotes: 2
Views: 53
Reputation: 10517
No locations are removed in described case, they just become orphaned. You should fetch locations and manually delete it before assign new set or implement special method to delete all orphaned locations.
Upvotes: 1