ios – Catch PrepareForDeletion occasion in context


I am dealing with an issue I couldn’t discover a resolution to.
We’re re-writing our DI, and in one in every of our CoreDataModel, we override the strategy prepareForDeletion and get a defaultInstance of our DI inside to carry out an operation (replace values of one in every of its relationship).

I used to be questioning if there was an alternative choice to catch the prepareForDeletion occasion, I attempted the notification despatched by the NSManagedObjectContext (didChange, willSave, didSave), however at this level it is too late.

Is there any willDelete or one thing like that notification that may be despatched ?

My second thought, was to create a customized NSManagedContext and override the strategy deleteObject to ship the notification, however I ain’t certain it’s going to do it if, for instance, we’re deleting mannequin in cascade.

The third thought, was to inject our DI instantly within the NSManagedObjectContext.

When you’ve got any result in obtain catch the prepareForDeletion occasion, I will be tremendous blissful as a result of proper now I am caught.