I have 2 nib files, MainMenu.xib, and another owned by an NSWindowController subclass. I've got 4 choices on a window panel, where only one of them can be selected (if another is selected, I want to set a check mark on the new one, and clear the other 3)
So I can easily tell which menu item was picked, by routing everything through the First Responder, and setting tags on the 4 menu choices.
Then, the selector which receives this action just looks at the tag, and takes the desired action. And, as part of the IBAction, I get a reference to the sender...so I know how to set the checkmark on it. Clearing the checkmark on the other menu item could also be done by using an iVar to keep track of the most recent clicked on sender, and then I could do this, as suggested by the Cocoa docs:
[currentItem setState:NSOffState];
[sender setState:NSOnState];
Now the problem boils down to the fact this is a document style app. The menu selection is global, so I'd have to add logic whenever a new document window takes focus, and similar logic when a window loses focus.
I found a method I could implement -windowDidBecomeMain
which tells me when my window controller became the main window. But I dont see a corresponding method that tells me that the old window lost focus so it can clean up.