macosnstableviewnstablecellview

Show elements of an array in an NSTableView


Assuming that I have this array of strings: var array = ["First", "Second", "Third"] I want to show each of the elements of this array in an NSTableView cell. I have created the function numberOfRowsInSection that returns the number of empty cells, but I can't figure out how to show the string elements.


Solution

  • You can use

    func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
            return array[row]
        }
    }