我创建了一个 NSTableCell 的子类,并将其作为表的数据源和委托。
该表是基于视图的。
该单元格是一个图像和文本单元格,我在其中添加了一个额外的文本字段。
我有一个子类中额外字段的引用出口。
我已将 IB 中表格视图单元格的额外字段引用出口连接到额外字段。
表中的所有内容仍然像以前一样工作,我将单元格视图子类化并将所有数据源和精细代码移到那里。
但是..我仍然无法像我预期的那样在子类中的微妙方法中引用新的额外字段。
请参阅下面我期望现在能够做的事情。但是 tableCellDate(单元格中的新字段)未被识别为可用参考。?
class SubclassOfNSTableCellView: NSTableCellView, NSTableViewDelegate{
@IBOutlet weak var tableCellDateField: NSTextField!
// other ib outlets are here
func tableView(tableView: NSTableView!,viewForTableColumn tableColumn: NSTableColumn!, row: Int) -> NSView! {
var cell = tableView.makeViewWithIdentifier("MainCell", owner: self) as NSTableCellView
var theDisplayName: String = recordingsDictionaryArray[row]["name"] as String
cell.textField?.stringValue = theDisplayName
// what i expected to be able to do below was
// cell.tableCellDateField.stringValue = recordingsDictionaryArray[row]["date"] as String
return cell;
}