我使用下面的代码等待 NSTimer 触发
-(void)timer1Fired :(NSTimer *) timer
{
isTriggered=true;
}
//----------------------------------------------
isTriggered=false;
[NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(timer1Fired:)
userInfo:nil
repeats:NO];
int j1 = 0;
while ( !isTriggered && j1 < 1000)
{
[NSThread sleepForTimeInterval: 0.5];
j1++;
}
//continue to do something //b
但看起来 NSTimer 永远不会被触发
欢迎任何评论