• 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
Windows and Default Notification Center
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Windows and Default Notification Center


  • Subject: Windows and Default Notification Center
  • From: Bruce Truax <email@hidden>
  • Date: Fri, 23 Jul 2004 11:08:36 -0400

In my Cocoa Document based app my window controller has a method which
handles messages which are sent to the default notification center. These
messages are typically commands for actions sent by various menu dialogs.
This method works great when there is one window open but when I have
multiple windows all windows receive the command. This is because each
window controller registers itself as a receiver when it is created.
Obviously I have to manage who receives these messages as windows are moved
to the front. I was looking for a window or window controller method which
is called as a window is made the key window but I cannot find one.


I register the with the default notification center as follows:

//register to recieve the ACCommandReady notification sent by the
dialogs

[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(processCommand:)
name:@"ACCommandReady"
object:nil];


I then use the following statements to send a command to the window
controller:

NSNotificationCenter *defaultCenter;
defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter postNotificationName:@"ACCommandReady" object:command];


The processCommand method in the window controller extracts the command from
the NSNotification object and passes it on to the appropriate handler.

What is the best way to handle these messages? I assume that somehow I
should be sending the messages to the first responder but I do not see a way
to pass a message with an argument to the first responder.

Thanks.

--
____________________________________________________________
Bruce E. Truax email: email@hidden
Optical Engineering Consultant

Diffraction Limited Design LLC
388 Wedgewood Road voice: 860-276-0450
Southington, CT 06489 fax: 860-620-9026
http://www.dld-llc.com
_____________________________________________________________

Bruce
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Windows and Default Notification Center
      • From: Public Look <email@hidden>
  • Prev by Date: Re: Problems with performSelector:withObject:afterDelay:
  • Next by Date: Re: forcing a dialog to be the active (front) window
  • Previous by thread: Re: AirTunes Details
  • Next by thread: Re: Windows and Default Notification Center
  • Index(es):
    • Date
    • Thread