IOS - 按下按钮时捕获事件并传递给 tableview

IOS - Capture event on button pressed and pass to tableview

我正在尝试从按下的按钮捕获事件,以便我可以将其传递给 table 视图,它是一个计时器,我可以在其中捕获时间并将其传递给 table查看,但我似乎无法捕获事件类型。

在下面的示例中,我可以捕获进球的时间,但我需要将“目标”一词也传递给 table视图

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell = UITableViewCell(style: UITableViewCellStyle.value1, reuseIdentifier: "cell")

        cell.backgroundColor = self.view.backgroundColor

        **cell.textLabel?.text = "Help here to capture the button event"**
        cell.detailTextLabel?.text = time[indexPath.row]

        return cell
    }


    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

        return time.count
    }

@IBAction func goalClicked(_ sender: UIButton) {

    let stopWatchString = stopWatch.elapsedTimeSinceStart()
    stopwatchLabel.text = stopWatchString

    time.insert(stopWatchString, at: 0)
    self.tableView.reloadData()        
}

谢谢

已排序。

var event: String!

然后在tableView中

cell.textLabel?.Text = event

终于在按钮功能里了

event = "Goal"
tableView.reloadData()