0

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...

Dror Chen
  • 51
  • 1
  • 10

1 Answers1

0

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

André Slotta
  • 13,774
  • 2
  • 22
  • 34
  • Is there any way for me to present a new view controller but not ontop of a one? – Dror Chen Nov 07 '15 at 22:12
  • tell me about your app. is the viewcontroller you posted the code from your rootviewcontroller? – André Slotta Nov 07 '15 at 22:13
  • i'm confused. in which viewcontroller did you implement the `deinit`? – André Slotta Nov 07 '15 at 22:15
  • i tried to simplify it for the question, but i added the deinit to the newviewcontroller. i started at the main, moved to the new, moved again to the main, and then again to the new and the second time i got to new i noticed that all of the "garbage" from the first time the new appeared stayed. – Dror Chen Nov 07 '15 at 22:17
  • can you show me what happens in the second viewcontroller? – André Slotta Nov 07 '15 at 22:48