Re: NSOutlineView + selectionIndexPaths binding
Re: NSOutlineView + selectionIndexPaths binding
- Subject: Re: NSOutlineView + selectionIndexPaths binding
- From: Quincey Morris <email@hidden>
- Date: Thu, 21 Jan 2010 11:49:23 -0800
On Jan 20, 2010, at 20:17, Andrew Shamel wrote:
> I have an NSOutlineView with its only column bound at treeController.arrangedObjects.name to an NSTreeController that manages a Core Data entity called Collection with the property "name."
>
> The NSOutlineView's dataSource IBOutlet is connected to a custom class CollectionViewController for the purposes of handling drag and drop.
>
> What I would like to do is bind the NSOutlineView's selectionIndexPaths binding to the NSTreeController's selectionIndexPaths key. When I do this, however, I get back this error:
>
> Illegal NSOutlineView data source (<CollectionViewController: 0x1001722d0>). Must implement outlineView:numberOfChildrenOfItem:, outlineView:isItemExpandable:, outlineView:child:ofItem: and outlineView:objectValueForTableColumn:byItem:
>
> and there is nothing in the NSOutlineView (or any other bound views for that matter).
>
> I tried implementing "dummy" versions of those NSOutlineViewDataSource methods (that return negative or nil values), as I have seen recommended in the archives, but this also results in a host of empty views.
>
> Have there been any developments on this front? Is there any way to bind the selectionIndexPaths binding while still using bindings for the NSOutlineView's data?
Your problem is nothing to do with selectionIndexPaths, but rather how you're using the data source.
Table & outline views have a content binding, which is an alternative to using a data source. If you provide neither binding nor data source (which is the typical case), then the view figures it out from the bindings of the columns themselves.
In your case, you've explicitly specified a data source, so the column binding is *just* the column binding. You must fully implement the data source methods, and they have to return real data. The only shortcut you can take is that 'outlineView:objectValueForTableColumn:byItem:' isn't actually going to be called -- since you only have one column, and *its* data is coming from its own binding.
Of course, if you've got to implement almost all of the data source anyway, then it might be easier to add the last piece and feed the column through the data source instead of a binding.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden