Roberto Sampaio Roberto Sampaio - 2 years ago 58
iOS Question

Do I need to invalidate 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?

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download