Why is an NSArrayController allowing removal of objects when there's no NSTableView selection?

StackOverflow https://stackoverflow.com/questions/18709596

문제

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?

도움이 되었습니까?

해결책 2

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.

다른 팁

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 belowenter image description here

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top