NSTimer20 秒ごとに関数を実行するために使用したいのですがNSTimer、関数に入れNSThreadます。コードは次のようになります。
-(void)func1
{
[NSThread detachNewThreadSelector:@selector(func2)
toTarget:self withObject:nil];
}
-(void)func2
{
[NSTimer scheduledTimerWithTimeInterval:3 target:self
selector:@selector(func3) userInfo:nil repeats:YES];
}
-(void)func3
{
//do something,but the function seems never be executed
}
したがって、問題は、func3 がNSTimerin func2 によって決して実行されないことです。何人かの人々は、NSTimer唯一の run in main thread.is it true??so Can't NSTimerstart in a NSThreadfunction?と言います。