Populate one column based on values of other column in a NSTableView

How do you populate one column based on values of other column for a macOS app using Xcode 12 in a tableView?

The value of the first column comes from a comboBox which I get control by using the following code connected to the comboBox:

Code Block
@IBAction func comboAction(_ sender: NSComboBox) {
        print("Combo selected", sender.selectedTag(), sender.stringValue, sender.indexOfSelectedItem, sender.identifier as Any)
        }

Then base on the value of the comboBox column within the comboAction function I want to populate column 2.

Can this be done? If so, how


Answered by BigEagle in 667986022
I know how I am going to proceed. I will build an array that I will update from the ComboAction and then use this array for the tableView as opposed to try to update the tableView cells directly.
Accepted Answer
I know how I am going to proceed. I will build an array that I will update from the ComboAction and then use this array for the tableView as opposed to try to update the tableView cells directly.
Here is how I would do:
You have a dataSource for the table, which is a 2 dimensional array. Right ?
array[column][row]

Then the second column array[1] should be computed based on the values of first column array[0]

So, when you change an item in column 0, recompute column 1 and ask for reloading with
func reloadData(forRowIndexes rowIndexes: IndexSet, columnIndexes: IndexSet)
Thanks Claude.. I got it working like I want using what I suggested above. Very similar to what you had suggested.
Populate one column based on values of other column in a NSTableView
 
 
Q