Thanks
Thanks

Reputation: 40339

How can I invoke a method automatically 20 times per second?

From JavaScript I am used to create an interval and specify the delay for re-calling the function, until I stop the interval. Is there something similar available on the iPhone? Any good links are highly appreciated. This goes to community wiki.

Upvotes: 0

Views: 179

Answers (1)

oxigen
oxigen

Reputation: 6263

//create and start timer

[NSTimer scheduledTimerWithTimeInterval: 0.05 target: self selector: @selector(timerMethod:) userInfo: nil repeats: YES];

// method works 20 times per second
-(void) timerMethod: (NSTimer*)theTimer {
NSLog(@"timer is working");
}

Upvotes: 5

Related Questions