【发布时间】:2017-06-24 14:11:10
【问题描述】:
我有两个表视图,您可以在其中将一行从表 A 拖到表 B。 这很好用。
但我需要知道,将从表 A 中拖出哪个行号。 这是我的表 A 的代码,也是问题:
func tableView(_ tableView: NSTableView, writeRowsWith rowIndexes: IndexSet, to pboard: NSPasteboard) -> Bool {
pboard.declareTypes([NSStringPboardType],owner: nil)
pboard.setString(persons[0].objectID.uriRepresentation().absoluteString, forType: NSStringPboardType)
return true
}
此刻我总是拖着“人”的第一个元素 我需要一个解决方案,我可以设置一个行号(或类似的东西)而不是静态的“persons [0]”。
有什么办法吗?
【问题讨论】:
-
rowIndexes怎么样? -
是的,我认为这是正确的方法,但我不知道如何使用它。人 [rowIndexes] 不起作用
-
好的,我知道了:persons[rowIndexes.first]
标签: macos cocoa swift3 drag-and-drop tableview