I have a screen with 2 buttons, A and B. When you press the buttons they go to the same view, with a button C. When pressed C depending
if you pressed A or B they go to different views.
I have something like this, but I have two problems. First, it't not working, even when I hardcode Button A to mealTableViewController.from. Second, I don't know how to pass witch button was pressed to mealTableViewController.from.
class HomeViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let mealTableViewController = segue.destination as? MealTableViewController else {
return
}
mealTableViewController.from = "Button A"
}
}
In the storyboard attached to HomeViewController there are two button with a Show segue to Meal Table View Controller
Then, I have MealTableViewController, with a button connected to the action boton, that depending the value of from, it transition to one screen or to other.
class MealTableViewController: UITableViewController {
var from: String?
@IBAction func boton(_ sender: UIButton) {
if from == "Button A" {
performSegue(withIdentifier: "ShowMealView", sender: self)
} else {
performSegue(withIdentifier: "ShowOther", sender: self)
}
}
override func viewDidLoad() {
super.viewDidLoad()
}
}


