Notifications not filtering on object ?
Notifications not filtering on object ?
- Subject: Notifications not filtering on object ?
- From: Robert Clair <email@hidden>
- Date: Wed, 19 Jan 2005 09:18:16 -0500
I've had a number of obscure bugs which seem to be caused by the
notification system not filtering on the object as requested.
Simplified example:
NSSomeClass* desiredInstanceOfClass;
NSSomeClass* differentInstance;
--------------------------------------------------------
[ [NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(myNotificationHandler:)
name: NSSomeNotification
object: desiredInstanceOfClass ];
-(void)myNotificationHandler:(NSNotification *)notification
{
//whatever
}
myNotificationHandler seems to be called even when the the notification
was posted by differentInstance.
I've taken to practicing safe notifications -
-(void)myNotificationHandler:(NSNotification *)notification
{
if ( [notification object != desiredInstanceOfClass] ) return;
//whatever
}
but I'm wonder what I'm missing here.
Thanks,
Bob Clair
_______________________________________________
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