• 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
NSNotificationCenter
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSNotificationCenter
      • From: Andy Lee <email@hidden>
    • Re: NSNotificationCenter
      • From: Graham Cox <email@hidden>
  • Prev by Date: Re: objc_msgSend_ptr
  • Next by Date: Re: NSNotificationCenter
  • Previous by thread: Loading mechanism with NSAtomicStore
  • Next by thread: Re: NSNotificationCenter
  • Index(es):
    • Date
    • Thread