在NSTableView中显示数组的元素

问题描述 投票:-5回答:1

假设我有这个字符串数组:var array = ["First", "Second", "Third"]我想在NSTableView单元格中显示该数组的每个元素。我创建了函数numberOfRowsInSection,它返回空单元格的数量,但我无法弄清楚如何显示字符串元素。

macos nstableview nstablecellview
1个回答
1
投票

您可以使用

func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
        return array[row]
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.