Re: KVO or Value Transformer?
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