Roberto Sampaio Roberto Sampaio - 9 months ago 53
iOS Question

Do I need to invalidade my NSTimer before calling popToRootViewController?

I have one UInavigationController and three UIViewControllers.

Let's call them nav, vcA, vcB and vcC.

nav contains vcA as root, and pushes vcB and then vcC.

I have a NSTimer at vcC and I called the function popToRootViewController.

NSTimer is working, even I'm at vcA (root of nav). Do I need to invalidate it in order to vcC releases?


When you instantiate NSTimer, do you set self (vcC) as its target? If so then you need to invalidate your timer or else vcC won't be released. I don't know how familiar you are with ARC, but when you set vcC as NSTimer's target, vcC's retain count is added by 1