• 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
defaultCenter's addObserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

defaultCenter's addObserver


  • Subject: defaultCenter's addObserver
  • From: John Love <email@hidden>
  • Date: Tue, 7 Oct 2008 11:26:19 -0400

From MyDocument's windowControllerDidLoadNib I call a method in MyController, which in turn calls:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(aSelector:) name:aName object:anotherControllerObject];

The docs state that this passed object is the object that is encapsulated [NSNotification object] in the NSNotification* passed to the selector.

This selector has a footprint =
   - (void) aSelector:(NSNotification*)sentNotification;

I pass another Controller, iboAnotherCtrl, as this object:

Later on I call within AnotherController:
[[NSNotificationCenter defaultCenter] postNotificationName:aName object:self];


.. and everything works.


Now here's the sticky .. the docs state that if this encapsulated [NSNotification object] = nil, the observer is notified when *any* encapsulated object is sent to the selector.


So just for whatever, I pass object:nil to addObserver:selector:name:object:. Then, within my selector I test for the type of passed encapsulated object and something(?) doesn't work. My selector gets called for my first new MyDocument. But when I open up a second new MyDocument, the Debugger complains about an invalid aSelector. I don't understand what's going on, so I'm looking for help.

Again, everything works just great when I pass a non-nil object to defaultCenter's addObserver:selector:name:object:

Thanks in advance,

John Love


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: defaultCenter's addObserver
      • From: j o a r <email@hidden>
  • Prev by Date: RE: [Disarmed] Re: NSNotificationQueue EXC_BAD_ACCESS problems
  • Next by Date: [Meeting] Toronto Area Cocoa and WebObjects Developer Group - October 21
  • Previous by thread: Re: Wasted Space and Kernighan
  • Next by thread: Re: defaultCenter's addObserver
  • Index(es):
    • Date
    • Thread