tags:

views:

109

answers:

2

Problem: I need to fire values to an object 10 times per second. I must be able to start firing and stop firing.

I've discovered that the delegate of an UIScrollView gets notified in about the same time intervals, no matter how fast the scrolling is. You can easily see that if you NSLog the deltas from the offset changes. There must be a way to start firing a message 10 times per second until something says "stop". But how?

+8  A: 

I would look into the NSTimer class. That should allow you to set up a timer with an arbitrary time span (and stop it when desired).

Eric Petroelje
+1  A: 

I'm not much of a Cocoa developer, but I'm pretty sure you want NSTimer.

Look into [NSTimer timerWithTimeInterval:invocation:repeats:], [NSTimer invalidate], and NSRunLoop.

Kevin Montrose
I like to just use the scheduledTimerWithTimeInterval... constructors, as those automatically add the timer to the current run loop for you.
Tyler