defaultCenter's addObserver
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