• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Notifications not filtering on object ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Notifications not filtering on object ?
      • From: "M. Uli Kusterer" <email@hidden>
  • Prev by Date: bug? login items launch changes window behavior?
  • Next by Date: Why do "loose" nibs take precedence over nibs in .lproj?
  • Previous by thread: bug? login items launch changes window behavior?
  • Next by thread: Re: Notifications not filtering on object ?
  • Index(es):
    • Date
    • Thread