PDA

View Full Version : NSOutlineView Group Item




hazkid
Apr 12, 2008, 12:23 AM
I would like to implement a Finder/iTunes sidebar for my app. I have an NSOutlineView with a data source and everything, except I can't seem to implement the outlineView:isGroupRow: delegate method. I've tried returning yes for all items, identifying by index, string value, and nothing seems to work. The outline view is in IB with highlight style "source list" (for the active blue/inactive gray background).
The examples on Apple.com (SourceView and DragNDropOutlineView) are so complex I can't navigate through them - they're designed for higher level programmers than me. All of their data is loaded from the system, resulting is tons of code that I simply can't wade through.

I can't believe something like this could be so difficult. There are virtually no examples on the web, either- most of them were written before Leopard, using special backgrounds and gradients for the highlighting.

Thanks in advance to anyone who can lead me in the right direction with this.



kainjow
Apr 12, 2008, 08:54 AM
Make sure you have the outline view's delegate set, since outlineView:isGroupRow: is a delegate method, not a datasource method.

Edit: here's a sample project I whipped up to demonstrate. I tried to keep it as bare minimum as possible.

hazkid
Apr 12, 2008, 04:06 PM
Wow. That sample project was incredible. It was simple enough to read! Thank you so much.

I had tried setting the delegate before, but it made my app crash, so I disconnected it, thinking "well, this can't be it".

But everything works great now.

kainjow
Apr 12, 2008, 04:40 PM
Wow. That sample project was incredible. It was simple enough to read! Thank you so much.

I always find it amazing that Apple's examples are so overly complex.

I've always wanted to start a site that hosts very basic sample projects that demo Cocoa features, but just haven't gotten around to it. Maybe soon ;)

But everything works great now.

Great! Glad it's working.

hazkid
Apr 14, 2008, 09:26 PM
That's a great idea. Its so hard to find simple, focused Cocoa examples online.