Reputation: 4902
I have a Core Data app I'm building for OS X. My xib file has an NSArrayController
that is bound to the AppDelegate
's managed object context. The NSTableView
in the window is bound to the array controller's arrangedObjects
. The individual columns are bound to the appropriate properties of the array controller's entity, and almost everything is working fine. Except that there's a button on the layout for removing objects which works even when there's no object selected.
It's target is the array controller's remove:
action and its Enabled
binding is set to the array controller's canRemove
key.
My guess is that there's some configuration of the array controller that I need to set so that it disallows removal of objects unless there's a selection, but I can't seem to find it.
What do I have to do to make is so that the array controller won't allow an object to be removed unless there's a selection in the table view?
Upvotes: 1
Views: 637
Reputation: 4902
It turns out that in addition to the bindings I mentioned, the NSTableView
also needs to be bound. Binding its Selection Indexes to the Array Controller.selectionIndexes
solved the problem.
Upvotes: 1
Reputation: 587
Yes there is addition thing you need to do in the configuration. You need to bind the button to Enable property - > Array Controller -> Selection - > Model Keypath -> "@count".. Below is the image which will help you to fix this issue.
Buttons binding on selection is shown in the image below
Upvotes: 2