Converting a constantly changing scalar value to a changing interval or frequency
Posted
by eco_bach
on Stack Overflow
See other posts from Stack Overflow
or by eco_bach
Published on 2010-06-11T01:50:33Z
Indexed on
2010/06/11
12:42 UTC
Read the original article
Hit count: 254
Although I'm coding in Objective C, this is more of a general programming question.
What is the best way to convert a constantly changing scalar value to a changing interval or frequency?
Right now every time the scalar value changes I am destroying the NSInterval
ie
[self.myTimer invalidate];
self.myTimer = nil;
and creating a new one, but this seems like a VERY expensive way to achieve my goal, since the changing scalar value in my case represents the horizontal velocity of a swipe.
For a rough analogy, think of the speed of a swipe being reflected in a visual metronome, the faster you swipe, the higher(shorter interval) the frequency of the metronome.
© Stack Overflow or respective owner