View based NSTableView editing

前端 未结 3 1299
无人共我
无人共我 2020-12-08 16:13

I\'m not sure what I\'m doing wrong. Since I couldn\'t find any other questions (or even documentation) about this, it seems do be normally working without problems for othe

3条回答
  •  自闭症患者
    2020-12-08 16:21

    Just a correction to the accepted answer - you should get the row and column using the tableView.row(for: NSView) and tableView.column(for: NSView. Other methods may not be reliable.

    @IBAction func textEdited(_ sender: Any) {
            if let textField = sender as? NSTextField {
    
                let row = self.tableView.row(for: sender as! NSView)
                let col = self.tableView.column(for: sender as! NSView)
                self.data[row][col] = textField.stringValue
    
                print("\(row), \(col), \(textField.stringValue)")
    
                print("\(data)")
            }
        }
    

提交回复
热议问题