When I start the app my initial view is MainViewController
.
Then on button click I move to AnotherViewController
.
performSegueWithIdentifier("myFirstSegue", sender: self)
On AnotherViewController
I have a button that should return me back to MainViewController
but I don't want to instantiate new but to use existing instance.
let storyboard = UIStoryboard(name: "Main", bundle: nil)
var story = storyboard.instantiateViewControllerWithIdentifier("MainViewController") as! ViewController
let navigationController = UINavigationController(rootViewController: story)
self.showViewController(navigationController, sender: nil)
With this code I create new so I lost data that I stored on that view.
How can I get existing instance and just move to it?
UPDATE
To explain issue better if on first view I have UISwitch
and move to another ViewController
and then get back to first I want to UISwitch
stay same not "reset".