Thanks Jim, unfortunately all occur either at pre-save or save time,
which is too late.
I'm basically looking to restore some state on an object at time of
deletion, e.g.
if A is associated with B via a to-many relationship from A->B, then
when one instance of B is deleted - we need to change a property on A.
Thanks
--
John Clayton
Skype: johncclayton
On 17/11/2008, at 10:59 PM, Jim Correia wrote:
On Nov 17, 2008, at 4:51 PM, John Clayton wrote:
I'm using core-data and need to know when a particular core-data
object (derived from NSManagedObject of course) is about to be
deleted. I'm deleting objects simply by using the managed object
context's deleteObject method, like this:
[[theObject managedObjectContext] deleteObject:theObject];
Is there a way to be notified immediately of the delete? I need to
know immediately, not only when the context is saved. Am I missing
something painfully obvious here?
now, I could of course put a 'deleteThisObject' method onto the
class I'm deleting, but isn't there a core-data way to handle this?
I've tried catching the
NSManagedObjectContextObjectsDidChangeNotification notification -
but that only fires on context saves, same with the
willTurnIntoFault method as well as the dealloc - all these methods
are only ever called when the context is being saved - which in my
case is (a) unpredictable, (b) too late .
Is -validateForDelete: time too late? If not, that's an option.
You can also try
[context deleteObject: object];
[context processPendingChanges];
... handle notification ...
[context save: &error];
Jim
_______________________________________________
Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [EMAIL PROTECTED]