On Thu, Oct 29, 2009 at 1:07 PM, Chunk 1978 <chunk1...@gmail.com> wrote:
> i've created an NSMenuItem in the MainMenu.xib that targets an action in a
> different XIB thru the first responder.  the action removes an object from
> the array.  however, i'd like to binn the NSMenuItem object to the array
> controller's canRemove controller key so that the NSMenuItem is only
> accassable when appropriate (when an item on the table view is highlighted
> and elegable for removal).  is it even possible to access bindings of an
> array controller that is in a different XIB?  is this possible?


 There isn't enough information about your application and its
architecture to give you a direct answer as to "how", but in general,
yes. It's mind-numbingly simple in some cases.

 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"

 The key to understanding this is to fully understand what "First
Responder" actually is in Cocoa, then understanding the overall
architecture of a Cocoa document-based application (and how to walk
the path).

 The approach for other situations (not targeting something in a
document) is similar - you just need to make sure every element in the
path is properly accessible via a KVC-compliant accessor.

 Note: All this has the prerequisite requirement of understanding
Cocoa (because Bindings is an advanced Cocoa technology) on a more
fundamental level (because Bindings is an advanced Cocoa technology),
so any questions about the specifics should not be lumped into one
broad-sweeping, all-encompassing thread. You'll want to "break it
down" and attack each piece as it comes.

--
I.S.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to