On Feb 11, 2015, at 1:25 PM, Steve Mills <sjmi...@mac.com> wrote:

> On Feb 11, 2015, at 13:06:20, Steve Mills <sjmi...@mac.com> wrote:
>> 
>> This also sparked my understanding of the other binding attributes, like 
>> Multiple Values Placeholder and such, resulting in me not needing my special 
>> EnableOnlyFor1ItemXformer value transformer on the array controller 
>> selectedObjects.@count binding. Duh. I guess when I decided to tackle Core 
>> Data, Cocoa bindings, NSTableView, and NSArrayController all at the same 
>> time, my brain quickly overflowed. :)
> 
> Wait, I guess my assumption about Multiple Values Placeholder was wrong. I 
> still need my transformer. Having multiple items selected does not cause the 
> Multiple Values Placeholder to be used. Reading NSPlaceholders now…

The selectedObjects property never returns those placeholders.  Only the 
selection property does that.  However, that wouldn't support @count, I don't 
think.

I believe it should work to bind to selection.self or something similarly 
innocuous.  Use the NSIsNotNil transformer to get a YES result by default.  
Then set the Multiple Values and No Selection placeholders to produce a 
different result for those cases.

You probably want to enable Always Use Multi Value Marker on the array 
controller.  By default, it compares the result of applying the model key path 
to all of the selected elements to see if they actually differ from each other. 
 If they're all the same, it produces the single value.  You've probably seen 
UIs where, if all selected objects have the same value, a checkbox reflects 
that one value.  If they have different values, the checkbox shows the mixed 
state ([-]).  This is what that's about.  You don't care about that and, 
anyway, the "self" key is never going to be the same across multiple elements.  
You avoid a performance hit by enabling Always Use Multi Value Marker.

However, this affects the array controller globally.  You can't restrict it to 
just this one binding.  So, be sure you don't want the default behavior 
anywhere else in your UI.

Regards,
Ken


_______________________________________________

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

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

Reply via email to