0

I'm struggling to setup the correct bindings to make a SourceView (OutlineView) in View-Based mode to work with a TreeController. It does work correctly in Cell-Based mode.

Unfortunately I can't find how to setup header&title text, all I get is empty stuff :≤≤

What I get :

enter image description here

XCode project if you feel like digging in :

https://www.dropbox.com/s/qz3m9p5vd2qvngb/MasterDetail.zip

Took the data from another post :

[
    {
        "itemName": "Item 1",
        "children": []
    },
    {
        "itemName": "Item 2",
        "children": [
            {
                "itemName": "Item 2.1",
                "children": []
            },
            {
                "itemName": "Item 2.2",
                "children": [
                    {
                        "itemName": "Item 2.2.1",
                        "children": []
                    },
                    {
                        "itemName": "Item 2.2.2",
                        "children": []
                    }
                ]
            }
        ]
    },
    {
        "itemName": "Item 3",
        "children": []
    }
]
Olivier
  • 3,431
  • 5
  • 39
  • 56

1 Answers1

2

You have to implement at least the -outlineView:viewForTableColumn:item: so the Outline View knows how to display the data. In your outline View datasource, implement the method like this:

- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item {

    NSView *cellView = [outlineView makeViewWithIdentifier:@"DataCell" owner:self];
    return cellView;
}

If tested this is your project and now the cells are displayed. Look at the NSOutlineViewData / NSOutlineViewDelegate Protocols for further informations.

florianbuerger
  • 422
  • 2
  • 9
  • I thought the purpose of bindings was to get rid of delegates? But that worked when adding a delegate to the `NSOutlineView` (in this case `AppDelegate`) & implementing your method. In my case, the `dataSource` is a generic `TreeController`. – Olivier Aug 17 '12 at 10:13