title: Swift - How to detect an action button in UItableViewCell is pressed from ViewController?
body: <p>I have an action button in UITableViewCell and I would like to detect when the button is pressed and the pressed cell's number from ViewController to make an audio play list in ViewController.swift.</p>
  
  <p>I have been stuck in this problem for a while and I would really appriciate your advice. Here are the codes.</p>
  
  <p>ViewController.swift</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
  
      @IBOutlet weak var tableView: UITableView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
          tableView.delegate = self
          tableView.dataSource = self
  
          tableView.register(UINib(nibName: "Cell", bundle: nil), forCellReuseIdentifier: "cell")
  
      }
  
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return 3
      }
  
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
          let cell = tableView.dequeueReusableCell(withIdentifier: "cell") as! Cell
          return cell
  
      }
  
  
  }
  </code></pre>
  
  <p>Cell.swift</p>
  
  <pre><code>import UIKit
  
  class Cell: UITableViewCell {
  
      @IBOutlet weak var button: UIButton!
  
      @IBAction func buttonPressed(_ sender: Any) {
  
          ***[Code to send the pressed cell's number to ViewController]***
  
      }
  
  }
  </code></pre>