title: Detecting cell whose button was tapped
body: <p>On the FirstVC I have a variable index:</p>
  <pre><code>var index = -1
  </code></pre>
  <p>, which keeps the information of cell's indexPath.row so I can know in which cell the button was tapped. (Each cell has its own button)</p>
  <p>I tried like this:<br>
  <code>CellForRow</code>:</p>
  <pre><code>cell.Btn.tag = indexPath.row
  cell.Btn.addTarget(self, action: #selector(detectButton), for: .touchUpInside)
  </code></pre>
  <p>and then:</p>
  <pre><code>@objc func detectButton(sender: UIButton) {
      self.index = sender.tag
  }
  </code></pre>
  <p>The secondVC is connected by the segue so I tried to send the index like this:</p>
  <pre><code>override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  if segue.identifier == &quot;MySegue&quot; {
              let vc = segue.destination as! SecondVC
              vc.element = self.elements[index]
          }
      }
  </code></pre>
  <p>It crashes there because the index was still <code>-1</code>. I thought that <code>@objc func detectButton</code>
  will be called before <code>prepareForSegue</code> but it is not.
  <br>
  Why? And is there any other solution to send the index to the secondVC?</p>