• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Bindings paradigm
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Bindings paradigm
      • From: Chris Hanson <email@hidden>
    • Re: Bindings paradigm
      • From: "John C. Randolph" <email@hidden>
  • Prev by Date: Re: NSThread sleepUntilDate
  • Next by Date: Re: 1 REALLY STUPID question Cocoa support for AppleScript
  • Previous by thread: Re: NSThread sleepUntilDate
  • Next by thread: Re: Bindings paradigm
  • Index(es):
    • Date
    • Thread