Re: What exactly happens when I use Core Data's 'Remove' button?
Re: What exactly happens when I use Core Data's 'Remove' button?
- Subject: Re: What exactly happens when I use Core Data's 'Remove' button?
- From: "Arthur C." <email@hidden>
- Date: Mon, 14 Aug 2006 15:34:31 +0200
NSManagedObjectContext offers a notification named
NSManagedObjectContextObjectsDidChangeNotification. Observe this and
take appropriate action upon the managed objects found in the user info
dictionary under the key NSDeletedObjectsKey.
I have tried that, but on removes I only receive an error message saying
'selector not recognized'. The code is as follows:
@implementation ObjectToBeRemoved // has n instances
-(void) awakeFromInsert // same for awakeFromFetch
{
// ...
[[NSNotificationCenter defaultCenter] addObserver: self
selector:@selector(handleDeletion:)
name:@"NSManagedObjectContextObjectsDidChangeNotification" object: nil];
}
- (void) handleDeletion: (NSNotification *) notification
{
if ([self isDeleted])
{
// unregister for KVO
}
}
I definitely want the observer to be 'self', as I need to remove it as KVO
observer. Therefore I also need the reference to the object that is
observing 'self', which is only available from inside this object.
Is this correct? I believe the handler should get called also when an object
is changed (in any way), added, or removed. But all I get is the error
message after using the remove button, and the handler does not get called
at all.
I hope you have a solution for this as well.
Best regards,
Arthur C.
_________________________________________________________________
MSN Search, for accurate results! http://search.msn.nl
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden