Search code examples
iosswiftuiviewcontrollerdeallocdeinit

Swift: UIViewController doesn't auto deiniting


I added to my UIViewController the code below:

deinit {
    print("DEINIT")
}

And then i used the code below:

let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
            let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("newViewController") as! MultiGameView

            self.presentViewController(nextViewController, animated:true, completion:nil)

But the deinit of the view controller didn't happen, what am i missing here?

My problem is that after i go back to the main viewcontroller, and then again to newViewController, the newViewController hasn't been deinit so his properties stay as they were and his variables too...


Solution

  • your viewcontroller simply does not get deinitialized at that point. your new viewcontroller gets presented "on top of it".