如何每秒自动调用一次方法20次?

时间:2009-05-07 13:10:58

标签: iphone cocoa-touch uikit

从JavaScript我习惯创建一个间隔并指定重新调用该函数的延迟,直到我停止间隔。 iPhone上有类似的东西吗?任何好的链接都非常感谢。这是社区维基。

1 个答案:

答案 0 :(得分:5)

//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");
}