Hi All, I'd like a function that sets up a timer, and can also change the frequency, but I just can't get it to work. If I call it more than once it just stops calling the timerLoop function altogether. I've tried so many things including not actually scheduling the timer in the setFrameRate function, but just saving the desired frameRate and setting a flag to notify that its changed, and in the next frame changing the time. I"ve tried not using the conveniance method but manually allocing the timer and adding to the current runloop, and releasing the old one before allocing the new one. But always same problem. First call to the function works, second and more calls don't. What am I doing wrong?

The function in its simplest form is below. How can I achieve what I want?

-(void) setFrameRate:(float)frameRate {
        [timer invalidate];
timer = [NSTimer scheduledTimerWithTimeInterval:(1.0f / frameRate) target:self selector:@selector(timerLoop) userInfo:nil repeats:YES];
}


Cheers,



Memo (Mehmet S. Akten)
        www.memo.tv
www.twitter.com/memotv
www.vimeo.com/memotv


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to