嗨,我想與另一個線程啓動一個計時器,並希望在該線程中重複進程。我曾嘗試過,但不起作用。下面如何運行另一個線程並使用該線程運行計時器來重複進程?
[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];
}
我的代碼片段給出任何人都可以建議我一個適當的方式做到這一點?
在此先感謝。
看看下面的鏈接 http://stackoverflow.com/questions/7055424/ios-start-background-thread – Pradeep 2013-04-29 10:30:27
感謝您的關注,但我要開始運行一個定時器,定時器線程將在30秒後重復 – jpd 2013-04-29 10:40:26