On May 21, 2009, at 2:15 AM, Quincey Morris wrote:

The obvious way of doing that is to bind 'Enabled' to the NSObjectController's "selection" controller key, (no model key), and use the value transformer NSIsNotNil. Anytime the selection is not nil, the control is enabled… right? It's super simple, but it doesn't work, and I don't see why not.

The documentation for [NSObjectController selection] says (in the discussion):

If a value requested from the selection proxy using key-value coding returns multiple objects, the controller has no selection, or the proxy is not key-value coding compliant for the requested key, the appropriate marker (NSMultipleValuesMarker, NSNoSelectionMarker or NSNotApplicableMarker) is returned. Otherwise, the value of the key is returned.

So nil is never returned (assuming none of the markers is defined to be nil).

Thanks. I hadn't realized/remembered it worked that way. I might need a refresher course on the finer details. :-)



You might try selectedObjects.count instead.


Yeah. Except there's no way to bind to that without a custom value transformer like Sean said.



It did occur to me that I could bind to the selection controller key and the "description" model key. Every object has a description. If it's nil, then there is no selection. That works, but is unintuitive. It seems like the proper thing to do would be to create a value transformer "NSIsNoSelectionMarker"



I wish Apple would beef up the default set of value transformers. I've had to write a few "obvious" ones.



Thanks guys,

--
Seth Willits



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to