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: "I. Savant" <email@hidden>
- Date: Mon, 14 Aug 2006 09:47:04 -0400
You need to be more descriptive. For example, you say you're
getting a "selector not recognized" ... what selector isn't
recognized? Is it "-handleDeletion:"? We could probably assume as
much, but if we assume wrong, we end up only wasting our time.
The point is, though someone may be able to tell you right away
what the problem is, most of the time you won't get good answers by
posting incomplete descriptions of your problems.
As to your problem ... at a guess, you're passing:
@"NSManagedObjectContextObjectsDidChangeNotification"
... when you should probably be passing ...
NSManagedObjectContextObjectsDidChangeNotification
Pass the constant, not what you think the constant is. For
example, NSManagedObjectContextObjectsDidChangeNotification may
actually equal 0 or [NSNumber numberWithInt:0] or even @"bob". That's
why you use the constant instead.
I don't know if this is your complete problem, but what you're
passing is definitely not right, so I'm willing to bet it's
definitely not helping. :-)
--
I.S.
On Aug 14, 2006, at 9:34 AM, Arthur C. wrote:
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:
40gmail.com
This email sent to email@hidden
_______________________________________________
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