I wanna change index of popUp button in NSTableView.
func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
let dataCell:NSPopUpButtonCell = tableColumn?.dataCell as! NSPopUpButtonCell
dataCell.addItems(withTitles: dataTypes)
return data.type //dataCell
}
func tableView(_ tableView: NSTableView, setObjectValue object: Any?, for tableColumn: NSTableColumn?, row: Int) {
dataSourceArr[row].type = dataTypes[object as! Int]
tableView.reloadData()
}
I can update my dataSource array but I can't update in tableView.
You can use NSTableViewDelegate's willDisplayCell method to achieve this.