开发者

Many-to-many relationship constrains in Core Data

I have entities Word a开发者_JAVA技巧nd Tag. Both have To-Many relationship to each other, as well as inverse. The way I need to constrain it that:

  • if I delete a Word then only the related Tags which has no Word pointing to them will be deleted
  • if I delete a Tag which has Words pointing to it then just nullify those set items.

Is it possible to model?


This is something that needs to be handled in code. You need to create custom subclasses for your Word and Tag entities and implement the -prepareForDeletion method in each. Then you can check the logic and handle it appropriately. I would also set the delete rule for the relationships between the entities as deny

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜