Re: Binding an objects "Enabled" to a button in IB
Re: Binding an objects "Enabled" to a button in IB
- Subject: Re: Binding an objects "Enabled" to a button in IB
- From: Joanna Carter <email@hidden>
- Date: Tue, 31 Aug 2010 08:34:44 +0100
Hi Jerry
>> Le 30 août 2010 à 13:26, email@hidden 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.
Eeeuuuwww!!!
It might work but is it really code as we know it Jim? ;-)
This kind of application design is too reminiscent of environments like Delphi and VS, where people are encouraged to write all their business logic in the form class. At least, in Cocoa, we have the encouragement to use controller classes.
Surely, if you already have a controller for the form, it's not really that much effort to add an outlet property to the class and bind to that.
Joanna
--
Joanna Carter
Carter Consulting
_______________________________________________
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