I'm having a hard time to sum up my problem in one title so I'll try to be clear here.
I have a UIViewController
(vc1) that links me to another UIViewController
(vc2) through a segue.
In vc2 I can select a segment of a UISegmentedControl
.
To go back to vc1, I simply press a return UIButton
I made where the @IBAction
is:
@IBAction func returnToMainView(sender: AnyObject) {
self.dismissViewControllerAnimated(true, completion: nil)
}
I would like that when I go back again to vc2, the segment I selected the first time is again selected.
What are my solutions?
Should I keep using the dismissViewControllerAnimated
method and use a delegate method to save which index segment is selected. Then when I go back to vc2, pass the selected index segment in the segue calling for vc2?
Or is there a better way to keep the state of my vc2 than the dismissViewControllerAnimated
?
Hope I've been clear enough.
UPDATE:
Here is some more information on my case.
In vc1, I have a UITableView. On every row I can call my vc2 which will display information according to the row of course.
And actually, I want to save the state of this controller just for the current execution of the app. No need to persist the state