I'm trying to use Bindings with NSOutlineView.
I cannot see how to connect the "currently selected item" to anything else via Bindings
I've tried:
- use NSOutlineView directly, bind to "selection" (开发者_开发技巧doesn't work; looking at the docs, Apple hasn't implemented that binding)
- use an NSArrayController, bind to "arrangedObjects", and bind the NSAC to the NSOV's "selectedRowIndexes" (doesn't work; you get a strange error message that "NSSet cannot be created from NSIndexSet"; (why not? surely, one is a subclass of the other?)
You don't use NSArrayController
for an outline view, you use an NSTreeController
. Then you can just bind to yourTreeController.selectedObjects
if you want to access the selection.
NSArrayController
is for use with NSTableView
, NSTreeController
is for use with NSOutlineView
.
Apple has a great example showing how to use NSOutlineView
with NSTreeController
.
NSOutlineView does support bindings:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/CocoaBindingsRef/BindingsText/NSOutlineView.html
精彩评论