I am creating a calculator app in which I need to set a variable in a separate view controller from a settings page. When attempting this feat some weird things happen. First, it somehow the variable returns nil. Then, it initialized a new view controller. Yet, all the non-static variables are the same when I reopen an instance of the old view controller.
There might be an error in my code:
func updateTag(title: String){
switch(title){
case "displayWithPrecisionSwitch":
let mainViewController = storyboard?.instantiateViewController(withIdentifier: "timerViewController") as! ViewController
mainViewController.updatePercision()
mainViewController.correctTallyDisplay?.refresh(totalTime: mainViewController.counter.getIntegerTime(), goal: mainViewController.counter.getGoal())
mainViewController.incorrectTallyDisplay?.refresh(totalTime: mainViewController.counter.getIntegerTime(), goal: mainViewController.counter.getGoal())
print(mainViewController.correctTallyDisplay?.percision ?? "Warning Nil")
default:
print("break")
break;
}
}
Or in the UI: enter image description here
I just need to find a way to call functions from "timerViewController".