Reputation: 4516
I need to have a least 1 element in a particular list.
So ideally I'd like to bind the enablement of the Delete button for this list to the Array Controller that provides the contents of this list and disable the Delete button for less than 2 elements.
I realize that I can easily disable the button if the list is empty via selectedObjects.@count
-
but is it possible to express the above condition using vanilla bindings without a custom value transformer, custom properties or the like..?
Upvotes: 1
Views: 56
Reputation: 90641
Haven't tried it, but might work:
Bind the Enabled binding to the array controller, controller key "selection", model key path "self". Use the NSIsNotNil
transformer, which will always be false. Then for the No Selection, Not Applicable, and Null placeholders, select No. For the Multiple Values placeholder, select Yes. For good measure, it's probably best to set the array controller to always use the Multiple Values placeholder when multiple items are selected.
But, really, just make the custom transformer and use that.
Upvotes: 1