N
N
nastya_zholudeva2018-07-09 11:57:58
Swift
nastya_zholudeva, 2018-07-09 11:57:58

How to pass cell index for each of two buttons?

How can I pass their cell index for the "Edit" and "Delete" buttons
5b43236c4bad0028615161.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
doublench21, 2018-07-09
@nastya_zholudeva

Where are you processing the click? Inside the cell itself?
UPD
You can get out like this: BUT this is the wrong approach, Read about MVC. You don't need to do this inside a cell.super.tableView.indexPath(for: self)

@IBAction func change(sender: UIButton) {
  
   for case let mycell as MyCustomCell in tableView.visibleCells where mycell.changeButton === sender {
      let indexPath = tableView.indexPath(for: myCell)
     // ...
   }

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question