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

允我心安 提交于 2019-12-11 01:43:58

问题


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;
}

来源:https://stackoverflow.com/questions/27102024/why-does-nstablecellview-alloc-init-produce-a-nil-text-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!