如何获取已编辑的 NSOutlineView 文本字段单元格的 "item" 或行索引?

How do I get the "item" or the row index of an edited NSOutlineView text field cell?

我将 NSOutlineView 与文本字段/文本字段单元格一起使用,如下图所示:

发送动作函数代码:

@IBAction func handleTextFieldDidEndEditing(_ sender: Any) {
    print("LeftNavBarOutlineView selectedRow: \(self.selectedRow)")
    print("LeftNavBarOutlineView editedRow: \(self.editedRow)")
    print("LeftNavBarOutlineView selectedRowIndexes.count: \(self.selectedRowIndexes.count)")

    let taskName = (sender as! NSTextField).stringValue
    print("LeftNavBarOutlineView " + taskName)
}

打印结果:

LeftNavBarOutlineView selectedRow: -1
LeftNavBarOutlineView editedRow: -1
LeftNavBarOutlineView selectedRowIndexes.count: 0
LeftNavBarOutlineView

问题:

"sender" 对象是一个 NSTextField 实例。我需要检索由我的 func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any 函数返回的 "item"

我要么需要直接获取 "item",要么需要行索引(我可以从我的地图字典中检索 "item")

由于 "sender" 是一个 NSTextField,我如何找出刚刚编辑过的行(或 "item")?

谢谢!

获取 row(for view and the item with item(atRow

的行
@IBAction func handleTextFieldDidEndEditing(_ sender: NSTextField) {
    let row = outlineView.row(for: sender)
    let item = outlineView.item(atRow: row)

outlineViewNSOutlineView 实例