Why does [[NSTableCellView alloc] init] produce a nil- text field?

725 views Asked by At

The log lines below will show "Table cell: [valid value logged here]" but "Text field: (null)".

I'm actually trying to build an NSOutlineView programmatically, and it works with a cell-based approach, but not with a view-based approach. Can someone tell me what I'm doing wrong?

-(NSView*)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item {
    NSTableCellView* view = [outlineView makeViewWithIdentifier:tableColumn.identifier owner:self];
    if (view == nil) {
        view = [[NSTableCellView alloc] init];
        view.identifier = tableColumn.identifier;
    }

    view.textField.stringValue = @"TEST";

    NSLog(@"Table cell: %@", view);
    NSLog(@"Text field: %@", view.textField);

    return view;
}
0

There are 0 answers