我怎样才能每秒自动调用一个方法20次?
问题描述:
从JavaScript我用于创建一个时间间隔,并指定重新调用该函数的延迟,直到我停止间隔。 iPhone上有类似的东西吗?任何良好的联系,高度赞赏。这涉及到社区wiki。我怎样才能每秒自动调用一个方法20次?
答
//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");
}