嗨,我想用另一个线程启动一个计时器,并想在那个线程中重复这个过程。我试过但它不起作用。
我的代码片段如下
[NSThread detachNewThreadSelector:@selector(setupTimerThread) toTarget:self withObject:nil];
-(void)setupTimerThread
{
NSLog(@"inside setup timer thread");
// self.startTiemr = [[NSTimer alloc]init];
startTiemr = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(triggerTimer) userInfo:nil repeats:YES];
runLoop = [NSRunLoop currentRunLoop];
[runLoop addTimer:startTiemr forMode:NSRunLoopCommonModes];
[runLoop run];
}
谁能建议我一个正确的方法来做到这一点?
提前致谢。