My question is if it is possible to pass data from a tableview cell that is selected to other view controller
The table view in the first controller uses a prototype cell
The second view controller has 3 other labels as shown here
I tried what is described here: passing data but it didn't work and gave me the error "Placeholder for UIStoryboardPopoverPresentationSegueTemplate" which I understand from reading this old thread top answer that is because I am using a prototype cell and its dynamic
what I want is that every time an user selects a row, the second view controller is filled with this relation
String 1 → String 4
String 2 → String 5
String 3 → String 6
So far I have tried a couple things like:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
let vc = storyboard?.instantiateViewController(identifier: "secondVC") as! CalculadoraViewController
present(vc, animated: true)
let string4 = string4array[indexPath[1]]
performSegue(withIdentifier: "secVC", sender: string4)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let vc = segue.destination as? CalculadoraViewController {
vc.string4.text = (sender as! String)
}
}
The popover view controller code:
class CalculadoraViewController: UIViewController {
@IBOutlet weak var string4: UILabel!
@IBOutlet weak var string5: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
}
}