How to properly cascade delete managed objects in Core Data?

后端 未结 2 1141
耶瑟儿~
耶瑟儿~ 2021-01-01 18:47

I have a Core Data model which has three entities: A, B, and C. A has a one-to-many relationship with B, and B has a many-to-many relationship with C. The delete rule for A

2条回答
  •  抹茶落季
    2021-01-01 18:59

    Based on the

    Any relationships belonging to C's whose associated B's were deleted, are also removed Suggests that the B-C should also have Cascade.

    Further, if B is removed, then C's should also be deleted. Again Cascade.

    • Nullify is often used as an inverse deletion rule*

    ie. Bs relationship to A is Nullify. C relationship to B is Nulllify. Such that when C is deleted, B is NOT deleted. And when B is deleted; A is NOT deleted.

    As in this winning drawing.

    A--->>B Cascade <---- Nullify

    B--->>C Cascade <---- Nullify

提交回复
热议问题