I have a program in which the user will enter data in one view controller and the information is calculated in another. I've gotten to the point where I can enter the data and when I segue to the SecondViewController I can access my data. But when I switch back to the first ViewController, the UITextFields are blank because the ViewController is re-instantiated.
Basically my application so far has one ViewController with two UITextfields and a SecondViewController that shows the data. I need a way to save the instance of the first ViewController when I am switching between the two.
I've tried using the answer from iOS Swift, returning to the same instance of a view controller , but yourVariable cannot be set to nil, so I got stuck there.
This is my code for segue-ing from the first ViewController to the SecondViewController
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
if (segue.identifier == "Show")
{
var destinationVC = segue.destinationViewController as! MainViewController
}
}
I only have a button that I press to go back to the first ViewController.