Andrea
Andrea

Reputation: 26385

Core data relationship delete custom rule

I'm facing that problem I've got 2 managed object subclasses connected by a "one-to-many" relationship. When I delete the parent I'd like to do some operations for each one of the children objects before it starts to delete all of them.
I know that I can do a custom delete for the parent object that does those operations before, but I'm wondering if exists some kind of notification or validation send before the deleting starts also for children objects.
What is the best approach?

Upvotes: 0

Views: 286

Answers (1)

bontoJR
bontoJR

Reputation: 7045

It's quite simple: just implement prepareForDeletion in your NSManagedObject subclass.

Alternative is to use:

- willTurnIntoFault
- didTurnIntoFault

For more info, Apple documentation is the way.

Upvotes: 3

Related Questions