Binding view-based NSOutlineView to Core Data

前端 未结 4 737
栀梦
栀梦 2021-01-31 11:26

I\'m trying to implement the new view-based OutlineView as a source list in my Mac app. I can\'t get values to display, though, so I made a small test app from the Core Data app

4条回答
  •  盖世英雄少女心
    2021-01-31 11:52

    I have created a little sample project which popuplates also popuplates an NSOutlineView, not with CoreData but the crucial factor is, like @boaz-stuller stated that the correct cell is selected (similar to how you handle UITableViewCells in iOS.

    So in my case I have implemented the method like so:

    - (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
    
        if ([self isHeader:item]) {
            return [outlineView makeViewWithIdentifier:@"HeaderCell" owner:self];
        } else {
            return [outlineView makeViewWithIdentifier:@"DataCell" owner:self];
        }
    }
    

    Check out besi/mac-quickies on github. Most of the stuff is either done in IB or can be found in the AppDelegate

    screenshot

提交回复
热议问题