1

In my app i have two entity:

enter image description here

Multiple 'Activities' has records inside. When i delete the last ActivityRecord entity in the Activities, i want to delete also Activities entity. I did 'nullify' the delete rule of whichDate but Activities not deleted.

Result is here:

enter image description here

Anamort
  • 341
  • 4
  • 17

1 Answers1

2

If you want to delete an Activities when it has no more ActivityRecords then... you have to delete the Activities. There is no way to automate this in Core Data. If you don't want to have any Activities objects with no related ActivityRecords, then you need to write your own code that deletes them.

When you're going to delete an ActivityRecord, you need to check the related Activities. If it doesn't have any more activity records, delete it too.

Tom Harrington
  • 69,312
  • 10
  • 146
  • 170
  • +1 for this answer. This can easily be extended by writing a generic method that you use to delete, so that you can use this for other entity/relationships as well. – LyricalPanda Apr 21 '14 at 16:37
  • Yes, there is no way to automate this in Core Data. Thank you so much. – Anamort Apr 21 '14 at 16:40