OutlineViews are very common in Mac interface, the better example is Xcode itself. So they should be widely documented. But they are only a few examples (like the Apple’s “SourceView” downloadable project), and they are in Objective-C and some of them rely on subclassing/overriding.
They are a number of concepts to understand if you want to use this class:
M: Of what kind is the data source? it is possible to use an already defined structure like a .plist?
V: The setup and the bindings of the NSOutlineView are unclear: how many columns? data or cell based?
C: What kind of controller to use? a dictionary or a tree controller?
The problem is, NSOutlineView may certainly be replaced with some other objects, like NSTableViews, but:
a) I’m not sure that to make a table view “look like” an outline view would be more simple than to implement a real outline view;
b) users are so familiar with outline views that presenting another interface would certainly confuse them.
So my request is: could somebody, using pure ASOC (without subclassing) and IB bindings explain to us how the whole thing works and give some hints to implement one of these NSOutlineViews?
The one you asked about, I can’t quite figure out, but the one above is equivalent to this in applescript:
if item is missing value then
return 1
else
return item's numberOfChildren()
end if
It’s just a C shortcut for an if-then-else statement.
You don’t necessarily need to implement those data source methods, you can also do outline views with bindings. I have an example that I made a while ago, but I’m not at my home computer now. I’ll send you a copy when I get home on Thursday or Friday.