I'm using CoreData and was wondering if I could somehow extend my NSManagedObjects to do custom stuff (like deleting files belonging to this instance).
In my case I have a couple of CoreData entities and each entity may have a folder or file path stored in a property. If the entity gets deleted I want this entity to take care of deleting the referenced files on its own.
Such behavior would be particularly helpful in combination with the "Cascade" deletion rule as removing an entity removes all child entities and their files.
If there is no such mechanism I would write a Category for each entity containing a custom deletion method, including cascading behavior for entities that may have children.
What would you do, is there an elegant solution to my problem? Has this been discussed before and I just haven't found it?
Thanks a lot!
Paul
You can do additional cleanup just before an object is deleted by overriding the prepareForDeletion
method in your NSManagedObject
subclass.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With