title: swift: segue on button click
body: <p>I want to move to the next controller on button click with using segue. I need to get number of press button in next controller.</p>
  
  <p>This is code from my controller:</p>
  
  <pre><code>import UIKit
  
  class ViewController2: UIViewController, UITableViewDelegate, UITableViewDataSource {
  
      @IBOutlet var tblTable: UITableView!
  
      var buttonTitles = ["One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"]
  
  
      override func viewDidLoad() {
          super.viewDidLoad()
          tblTable.delegate = self
          tblTable.dataSource = self
      }
  
  
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return buttonTitles.count
      }
  
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "buttoncell") as! ButtonCell
  
        let buttonTitle: String = buttonTitles[indexPath.row]
        cell.btnButton.setTitle(buttonTitle, for: .normal)
        cell.btnButton.tag = indexPath.row
        cell.btnButton.addTarget(self, action: #selector(self.buttonClick(button:)), for: .touchUpInside)
        cell.selectionStyle = .none
        return cell
     }
  
     @objc func buttonClick(button: UIButton) -&gt; Void {
      print("btnButton clicked at index - \(button.tag)")
      button.isSelected = !button.isSelected
  
      if button.isSelected {
          button.backgroundColor = UIColor.green
      } else {
          button.backgroundColor = UIColor.yellow
      }
    }
  
  }
  
  
  class ButtonCell: UITableViewCell {
  
      @IBOutlet var btnButton: UIButton!
  
      override func setSelected(_ selected: Bool, animated: Bool) {
          super.setSelected(selected, animated: animated)
  
          if selected {
              btnButton.backgroundColor = UIColor.green
          } else {
              btnButton.backgroundColor = UIColor.yellow
          }
  
      }
  
      override func setHighlighted(_ highlighted: Bool, animated: Bool) {
          super.setHighlighted(highlighted, animated: animated)
  
          if highlighted {
              btnButton.backgroundColor = UIColor.green
          } else {
              btnButton.backgroundColor = UIColor.yellow
          }
      }
  }
  </code></pre>
  
  <p>How to solve the problem it with my code?</p>