Re: problems resetting timer interval.
Re: problems resetting timer interval.
- Subject: Re: problems resetting timer interval.
- From: Memo Akten <email@hidden>
- Date: Wed, 4 Feb 2009 00:46:31 +0000
Hi Ron, thanks for the reply. Turns out I had an error somewhere else,
my code works fine now :P
Cheers,
Memo.
Re: problems resetting timer interval.
Ron Fleckner
Thu, 29 Jan 2009 16:02:14 -0800
I basically do the same and it works for me, but there are some slight
differences.
Translating my setup into your terminology, I have an ivar float
frameRate; It has accessors - (float)frameRate and -
(void)setFrameRate:(float)newRate;
Then in my IBAction method which the user calls via the GUI, I set the
new frameRate and call a -stopTimer method which invalidates the
timer, then still in the IBAction method call a startTimer method
which simply does what your "timer = [NSTimer scheduledTimer... ]
method does.
Perhaps breaking out the parts like that helps? I don't know.
HTH,
Ron
On 29 Jan 2009, at 22:07, Memo Akten wrote:
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 (email@hidden)
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:
This email sent to email@hidden