LoginSignup
3
2

More than 5 years have passed since last update.

[Swift] Segueの画面遷移でUITableViewの選択されたCellを取得する

Posted at

[Swift] Segueの画面遷移でUITableViewの選択されたCellを取得する

class myController: UITableViewController {
    var objects = [myModel]()

    override func prepare(for segue: UIStoryboardSegue, sender: Any!) {
        if segue.identifier == "toNextController" {
            if let indexPath = tableView.indexPath(for: sender as! UITableViewCell) {
                let object = objects[indexPath.row]
            }
        }
    }
}
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2