I have an iOS app consists of three view controllers
homeViewController -> newGameSelectionViewController -> GameViewController
In GameViewController
, I have a "home" button that should close the view controller and return to the newGameSelectionViewController
.
In newGameSelectionViewController
,
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
gameVC = segue.destinationViewController as! GameViewController
gameVC.countdown = 60
}
Then, I created an unwind segue
to newGameSelectionViewController
from GameViewController
.
In newGameSelectionViewController,
@IBAction func unwindFromHomeButton(segue: UIStoryboardSegue) {
gameVC.dismissViewControllerAnimated(true, completion: nil)
}
When I press the home button in GameViewController
, view closes and returns to the newGameSelectionViewController
The problem is, after pressing the home button and returning to the newGameSelectionViewController
, countdown timer in GameView
controller still continues. If I open an another GameViewController
, it also open a completely new view controller. In another words, first GameViewController
did not close by calling dismissViewController()
. How do I close the ViewController
completely so that if I start a new game, previous view controller does not continue counting at the background.
I am printing the countdown values with println()
in GameViewController
. Thats where I see the previous countdown values are still printing after dismissViewController()