On May 20, 2009, at 22:35, Seth Willits wrote:

I have an NSObjectController whose Content item is bounds to an object's "thing" path. I can then bind the values of controls in my nib to model key paths through that NSObjectController in the usual way. Those Value bindings can use "Conditionally Sets Enabled" and they work great.

I have some controls where I'm not binding the Value though, and instead just need to bind Enabled alone, so that when there is no selection in the controller, those controls are disabled.

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).

You might try selectedObjects.count instead.


_______________________________________________

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