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