[MacRuby-devel] ruby structure for NSOutlineView

François Boone francois.boone at usherbrooke.ca
Sat Nov 26 11:27:00 PST 2011

In the same way that this tutorial (http://developer.apple.com/library/mac/#featuredarticles/UsingMacRuby/_index.html), I try to implement a NSOutlineView controller in ruby to make a simple tree in the left part of a window.
I read the documentation of NSOutlineView, tasks and I understand I have to write at least four methods in my controller class:
	• – outlineView:child:ofItem:
	• – outlineView:isItemExpandable:
	• – outlineView:numberOfChildrenOfItem:
	• – outlineView:objectValueForTableColumn:byItem:
My questions are:
1) what kind of object I have to use in ruby to fit with outlineView structure?
If I understand I need a structure like:
Parent_1 : child 1, child 2
Parent_2 : no child
Parent_3 : child 1, child 2, child 3
2) Is a Hash like this:
Hash[ "Parent_1" => ["child 1", child 2"], "Parent_2", Parent_3 => ["child 1", "child 2", "child_3"]]
can be the solution?
3) where I can find this kind of information: the mapping between ruby data structure and NSObject data structure (for future use)?
4) and the last one: I think I do not understand what is item in the last method:
– outlineView:objectValueForTableColumn:byItem:
item: An item in the data source in the specified tableColumn of the view.
So, if I want to make a simple tree, I should have just one column, and then item should be Parent_x or child_x: Is it right?

Thank you for reply

More information about the MacRuby-devel mailing list