【发布时间】:2016-11-17 10:51:09
【问题描述】:
我想从一个数组中捕获信息并将其显示到我的 NSTableView 中。我不确定我需要为此做什么(我对 Swift 和一般编程非常陌生)。
我的表格视图如下所示:
我想从我的数组中获取值名称,并使用 NSTableView 将其显示在名称表中。我找到了this tutorial on Ray Wenderlich,但代码已经过时了,我不想在我的项目中使用旧的东西,这些东西在较新的操作系统版本中可能不再适用。
看来我需要[NSTableViewDataSource numberOfRows][3] 和viewFor。
关于如何做到这一点的任何例子 - 也许有人在几周前用 Swift 3 做了这个? :D
数组中的信息将由以下生成:
var devices = [Device]()
let quantityDevices = quantityData.intValue
for i in 0...quantityDevices-1 {
let newDevice = Device()
print("created new device")
newDevice.name = titleData.stringValue + "-\(i)"
devices.append(newDevice)
}
print("now we have \(devices.count) devices in our array")
}
【问题讨论】: