Binding visibility to arrayController selection

135 Views Asked by At

I have a NSTableView bound to a NSArrayController.

I have two buttons below the table that must be enabled only if there is an element selected on the table.

I select the buttons and bind Availability Enabled to Table1 Controller, selectedObjects but I get this error

Cocoa Bindings: Cannot create BOOL from object <_NSCachedIndexSet: 0x60000023b4e0>(no indexes) of class _NSCachedIndexSet

What is obvious, because selectedObjects is an NSIndexSet and the property is expecting a Bool.

In fact the buttons should be enabled if selectedObjects is not nil and disabled if that property is nil.

How do I do that? I mean, create a bool out of an array property so I can bind it.

1

There are 1 best solutions below

2
vadian On BEST ANSWER

Set Controller Key to selectedObjects and Model Key path to @count