Re: Binding To Array Controller From A Different XIB?
Re: Binding To Array Controller From A Different XIB?
- Subject: Re: Binding To Array Controller From A Different XIB?
- From: Quincey Morris <email@hidden>
- Date: Thu, 29 Oct 2009 10:57:56 -0700
On Oct 29, 2009, at 10:32, I. Savant wrote:
I assume the menu item is a main menu item in your MainMenu.xib? Is
the 'the other' xib the document prototype for an NS*Document-based
application?
If so, you can bind to File's Owner, using the path,
"mainWindow.windowController.document.property", where "property" is
whatever property you want.
You'd need to make the array controller (let's call it
"peopleArrayController") available via KVC-compliant accessor, but the
full keypath in your case would be:
"mainWindow.windowController.document.peopleArrayController.canRemove"
Perfectly true, but in this case I'd suggest this is the wrong approach.
<pause to climb on soapbox>
The whole point of targeting "first responder" is to allow different
objects to have control of the menu item at different times. [The case
of having even just one controlling object, but in a different NIB
from the main menu NIB, is a special case of this.]
The natural mechanism for controlling the appearance of such a menu
item (including its text, its check mark and its enabled state) is to
use interface validation (validateUserInterfaceItem: or
validateMenuItem:) in each possible controlling class.
The controlling object in this case, where the dependency is
ultimately on a NSArrayController property, is likely to be either the
NSDocument subclass, or the relevant window controller (set as a
window delegate to get it into the NSResponder chain).
Under the circumstances, interface validation is likely to be a whole
lot simpler than using KVO.
_______________________________________________
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