Detect UIButton from Custom UITableViewCell in Swift 3
<p>I have a custom UITableViewCell in which I have connected my UIButton using Interface Builder</p>

<pre><code>@IBOutlet var myButton: UIButton!
</code></pre>

<p>Under cell configuration of UITableViewController, I have the following code:</p>

<pre><code>override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {

var customCell = tableView.dequeueReusableCell(withIdentifier: self.MY_CELL_IDENTIFIER, for: indexPath) as! myCustomCell

// CONFIGURE OTHER CELL PARAMETERS

customCell.myButton.tag = indexPath.row

customCell.myButton.addTarget(self, action: #selector(myButtonPressed), for: UIControlEvents.touchUpInside)

return customCell

}
</code></pre>

<p>Finally, I have </p>

<pre><code>private func myButtonPressed(sender: UIButton!) {
        let row = sender.tag
        print("Button Sender row: \(row)")            
    }
</code></pre>

<p>This code is not working, unless I change the function definition to below:</p>

<pre><code>@objc private func myButtonPressed(sender: UIButton!) {
            let row = sender.tag
            print("Button Sender row: \(row)")

        }
</code></pre>

<p><strong>Is there a better way to implement UIButton on custom UITableViewCell in Swift 3</strong></p>