Handling menu events in cocoa
How to handle the menu bar events, that is if i press "quit" or "about" option in 开发者_C百科the menu bar where the control comes.
Thanks in advance,
To understand this, you'll need to read up on the responder chain. You'll want to pay particular attention to the section titled "Action Messages" at the bottom of the page I linked. A nil-targetted action gets sent to the First Responder. This is how menu items usually work.
In the case of About or Quit, these actions get sent to the MainMenu.xib's File's Owner, which is your NSApplication instance. These actions are, respectively, -orderFrontStandardAboutPanel: and -terminate:. Since these actions are built into the NSApplication class, you don't have to handle them at all. Just leave the menu items wired as they are.
精彩评论