I work with swift 3 and I have a NSTableView (3 columns). I fill the data like below:
func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? {
var cellIdentifier = String()
var cellText = String()
switch tableColumn {
case tablewView.tableColumns[0]?:
cellText = "100"
cellIdentifier = "Cell1"
break
case tablewView.tableColumns[1]?:
cellText = "100"
cellIdentifier = "Cell2"
break
case tablewView.tableColumns[2]?:
cellText = "100"
cellIdentifier = "Cell3"
break
default: break
}
if let view = tableView.make(withIdentifier: cellIdentifier, owner: nil) as? NSTableCellView {
view.textField?.stringValue = cellText
return view
}
return nil
}
Now I would like to sum all values of column 1, every time when the selection will change. how can I realize this?