user1469734 user1469734 -3 years ago 170
Swift Question

IndexPath Swift TableView clicked column

With the following code I get the indexPath of the clicked button in the tableview:

@IBAction func btnClick(_ sender: UIButton) {
let hitPoint = sender.convert(, to: self.tableView)
if let indexPath = self.tableView.indexPathForRow(at: hitPoint){

The first print is
[3, 0]
when I clicked on the 3th row I get the
, but I need the other value. The
in this case.

Answer Source

indexPath returns [section, row].

If you want to access section (the thing you referred to as column ) , use indexPath.section

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download