addTarget for button in tableView
<p>I'm trying to add the download button for some items in my tableView. I've created the custom cell class and added the label and the button outlets, everything is working in displaying the info and even the buttons are showing where it should be.</p>

<p>I'm trying to add the target, but it does nothing. I need to pass the row index to the buttonClicked function or should I create this function in the custom cell class and then do the action some how? I would like to know the best practise of this.</p>

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

        let cell = tableView.dequeueReusableCell(withIdentifier: "PlaylistCell", for: indexPath) as! PlaylistTableViewCell

        let playlist = self.playlists?[indexPath.row]

        cell.titleLabel.text = playlist?.getTitle()


        if (playlist?.isOfflineAvailable())! {
            cell.downloadButton.isHidden = false
        } else {
            cell.downloadButton.isHidden = true
            cell.downloadButton.tag = indexPath.row
            cell.downloadButton.addTarget(self, action: #selector(buttonClicked(sender:)), for: .touchUpInside)
        }

        return cell
    }

    func buttonClicked(sender: UIButton) {
        let buttonRow = sender.tag
        print(buttonRow)
    }
</code></pre>

<p>I've also tried removing the (sender:) from #selector, but it does not change a functionality.</p>