On 2010 Aug 30, at 05:42, Joanna Carter wrote:

> The usual way to handle this would be to have a simple boolean property on 
> the controller class…

True, but let's answer the poster's question,

> Le 30 août 2010 à 13:26, co...@wamundson.eu a écrit :
> 
>> Can this binding be done … completely in the nib file (in IB)?

The answer is yes because the controller Joanna refers to may be an 
NSObjectController from the Library in IB.

Because the "Bind to" popup in Interface Builder's Inspector ▸ Bindings only 
shows the "controller" objects to which controls are typically bound, you 
cannot bind the Enabled binding of a text field directly to, say, the state of 
a button in Interface Builder.  But sometimes Apple leaves little hooks for 
"the other 20%" of us to do it Our Way.  Drop in an NSObjectController, and 
bind the text field's Enabled binding instead to the object controller with 
Controller Key = "content".  Then, bind the Value binding of the button to the 
same object controller with same Controller Key = "content".  Voila.

A similar arrangement allows one to codelessly bind a tab view's selected item 
to a segmented control.

Establishing bindings which IB doesn't sanction like this is one of the two 
uses I've discovered for what I once thought was a rather lame device.  In this 
case, think of NSObjectController as a RCA-phono to phone-plug adapter. 

_______________________________________________

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