Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nickculbertson

macrumors regular
Original poster
Nov 19, 2010
226
0
Nashville, TN
I have a View based application where I switch views with presentModalViewController. On my RootView I have an animation loop triggered by an NSTimer that plays continuously in the background while I'm viewing my SecondView. My question is, how can I stop the animation in RootView from running when I've selected the SecondViewController? I would like to resume the animation when I return to the RootView. Should I invalidate the NSTimer then create it again?

Thanks,
Nick
 
Instead of invalidating the timer, have you considered setting a flag and then checking the flag within the selector method to decide whether to animate or not? I guess an approach like this would be okay as long as the timer is not firing very frequently. If it is, the overhead of it firing might need to be considered when keeping it running.
 
Thanks Dejo.

Yeah, it is firing every .02 seconds. The animation is of four menu buttons moving like in this VIDEO at 0:32. The animation working in the background is eating up the memory for the rest of my app. I'll do some more research on the subject but if you think of any other suggestions shoot 'em my way.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.