Bindings paradigm
Bindings paradigm
- Subject: Bindings paradigm
- From: Gwynne <email@hidden>
- Date: Sat, 10 Jul 2004 16:18:50 -0400
I apologize if this message appears on the list twice; I originally
sent it from the wrong email address and I'm pretty sure the list
doesn't accept unsubscribed posters.
I've been working with bindings lately, and I have a question about
design...
Taking an example, I have a button that's only enabled based on the
settings of certain keys within my model object, but the logic can't be
expressed using the multiple-value form of the "enabled" binding (i.e.
it's more complex than an AND on each relevant key). There are two
basic ways to deal with this:
1) Watch for changes to the relevant keys in code and use [NSButton
setEnabled:].
2) Create a new key in the model object that encapsulates all the logic
and returns the BOOL value (or an [NSNumber numberWithBool:], it
doesn't matter as I understand it), and bind "enabled" to that key.
#2 is pretty simple, but to me it seems to violate the principle of KVC
because it doesn't represent any data in the model but rather a state
of the view that would have been the controller's responsibility before
bindings came along.
So my question for everyone who's been using bindings is which way
would you prefer? Should I implement a [sub]controller object that
KVO's on the keys and talks to the view directly, or expose the logic
as another key on the model? Or is there another option I'm missing?
-- Gwynne, key to the Code that runs us all
Email: email@hidden
Web:
http://musicimage.plasticchicken.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.