title: NSOutlineView Source List without a NIB
body: <p>I am trying to figure out how to do a source list 100% in code. I've been hacking away at SideBar demo and various SO questions/answers and have gotten close, but not quite there. I've copied my code below, this seems to work in that it does build a view, with 3 empty cells I can select. What I can't quite figure out is how to get my text to show up in those cells. I will ultimately replace that with my own view, but I'd settle for the stock rendering to work for now..</p>
  
  <p>In my controller:</p>
  
  <pre><code>@implementation SourceListController {
      NSScrollView *_scrollView;
      NSOutlineView *_sourceList;
      SourceListDataSource *_sourceListDataSource;
  }
  
  - (void)loadView {
      _scrollView = [[NSScrollView alloc] init];
  
      _sourceList = [[NSOutlineView alloc] init];
      _sourceListDataSource = [[SourceListDataSource alloc] init];
  
      [_sourceList setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList];
      NSTableColumn *c = [[NSTableColumn alloc] initWithIdentifier: @"Column"];
      [c setEditable: NO];
      [c setMinWidth: 150.0];
      [_sourceList addTableColumn: c];
      [_sourceList setOutlineTableColumn:c];
      [_sourceList setDelegate:_sourceListDataSource];
      [_sourceList setDataSource:_sourceListDataSource];
  
      [_scrollView setDocumentView:_sourceList];
      [_scrollView setHasVerticalScroller:YES];
  
      [_sourceList reloadData];
  
      NSLog(_sourceList.dataSource == _sourceListDataSource ? @"YES" : @"NO");
  
      self.view = _scrollView;
  
  }
  </code></pre>
  
  <p>And in my data source/delegate:</p>
  
  <pre><code>@implementation SourceListDataSource {
  
  }
  
  - (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
      return item == nil ? 3 : 0;
  }
  
  - (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item {
      return [NSObject new];
  }
  
  - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item {
      return item == nil;
  }
  
  - (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
      NSLog(@"Here %f", tableColumn.width);
      NSTableCellView *result = [[NSTableCellView alloc] init];
      NSTextField *textField = [[NSTextField alloc] init];
      [textField setStringValue:@"Test"];
      [result addSubview:textField];
      return result;
  }
  </code></pre>
  
  <p>UPDATE: Further digging tells me viewForTableColumn doesn't even get called.. I am stumped as to why..</p>
  
  <p>UPDATE 2: Figured out that it was the missing column and outlineTableColumn leading to not calling the delegate method. I fixed that and updated the code, but still no text shows up.</p>