• 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
Re: KVO or Value Transformer?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KVO or Value Transformer?


  • Subject: Re: KVO or Value Transformer?
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 2 Apr 2009 13:16:29 -0700

On Apr 2, 2009, at 11:53, Trygve Inda wrote:

I need to enable a view if the value of a popup menu is kSomeValue or
kSomeOtherValue, and disable it otherwise.

The popup's value is bound to an NSNumber in a NSDictionary.

I think I could add an observer for this and manually enable/disable the
view when the popup value meets my criteria...


or

I could use a custom value transformer that returns a Boolean and convert
kSomeValue and kSomeOtherValue to YES, everything else to NO and bind the
enabled state directly to the popup value, with the transformer.


Which is the better way?

Or behind door #3:

Write a derived property that returns YES or NO based on what's in the dictionary, and have keyPathsForValuesAffecting<DerivedProperty> (or the Tiger equivalent) return the keypath to the dictionary property key (i.e. something like "myDictionary.popupValueKey") -- and bind to the derived property.

Of course, in all 3 solutions, you need to pay due attention to the KVO-compliance of changes to the popup value in the dictionary.


_______________________________________________

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


References: 
 >KVO or Value Transformer? (From: Trygve Inda <email@hidden>)

  • Prev by Date: Re: [Q] doubleAction on a NSTableView misbehaving?
  • Next by Date: Re: [Q] doubleAction on a NSTableView misbehaving?
  • Previous by thread: KVO or Value Transformer?
  • Next by thread: re: core data, opening a previously saved xml file... bug/glitch/unexpected behavior
  • Index(es):
    • Date
    • Thread