For learning purposes i would like to convert a cell-based NSOutlineView to a view-based one,
basically i would like the following:
- instead of a normal cell, i’d like an ‘image and text table cell view’
- the image can be the stock NSApplicationIcon and the text can just be ‘hello world’ 🙂
- I’d like to do this without using bindings and
NSTreeController
Here is the ‘worlds simplest NSOutlineView’ example http://www.cocoasteam.com/Cocoa_Steam/Worlds_Simplest_Demo.html
I wonder if someone could modify it to make it view-based and work like i said above 🙂 🙂
I’ve tried looking at apple examples, and searching elsewhere on the internet but i still can’t get it to work – so thanks very much in advance 🙂
OK, so you want an
NSOutlineViewwithImageAndTextCellcells, right?Let’s do one of the most typical examples of this kind : a simple file explorer.
What we’ll need :
NSOutlineView(put an outline to your AppDelegate, asfileOutlineView)NameColumn,SizeColumn,ModifiedColumnNow, as for the rest, I’ll do it all programmatically, so that you get a good idea of what’s going on…
How to set it up (e.g. in
- (void)awakeFromNib):Connecting the dots :
Hint :
ImageAndTextCellclass can be found here. You’ll also notice a few other methods I’m using, which are obviously NOT supported by Cocoa (e.g.isFileHidden,isFolderorfolderContentsWithPathAndBackIgnoringHidden) but it’s not that difficult to implement them yourself…)