NSNotificationCenter
NSNotificationCenter
- Subject: NSNotificationCenter
- From: John Love <email@hidden>
- Date: Fri, 26 Sep 2008 08:14:14 -0400
Within MyController, I call:
notifyCenter = [NSNotificationCenter defaultCenter];
[notifyCenter addObserver:self
selector:@selector(mySelector:)
name:@"StatusChanged"
object:sentNotifyObject];
// We will be the observer and sentNotifyObject will equal the
// object encapsulated in the NSNotification passed to the
selector.
// When this encapsulated [NSNotification object] = nil, the
observer
// is notified when *any* encapsulated object is sent to the
selector.
and mySelector looks like:
- (void) mySelector:(NSNotification*)sentNotification {
MyController *theNotifyObject;
theNotifyObject = [sentNotification object];
if (theNotifyObject == myOtherController) {
}
}
=====
Note that the sent notifyObject encapsulated in the NSNotification is
a different controller than the observer, myController.
Now, the questions. It appears that everytime I see a need to check
the Status, I need to call:
- (void) postCalculationStatusChanged:(id)sentNotifyObject {
[notifyCenter postNotificationName:StatusChanged
object:sentNotifyObject];
}
Shouldn't my call to -addObserver automatically monitor
"StatusChanged" rather than my having to -postNotificationName??
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