这个警告导致一个严重的问题,因为我真的无法使用Xcode 9 beta 2在主线程之外调用委托.奇怪的是,当我使用Xcode 8.3.3时,这是有效的.
另外我认为只从主线程调用委托只是好习惯,不是吗?那么为什么这会导致应用程序崩溃呢?
我正在尝试使用NSTimer创建一个Stop-watch样式计时器,每0.1秒递增一次,但有时它似乎运行得太快了.
这就是我做到的方式:
Timer =[NSTimer scheduledTimerWithTimeInterval: 0.1 target:self selector:@selector(updateTimeLabel) userInfo:nil repeats: YES];
Run Code Online (Sandbox Code Playgroud)
然后:
-(void)updateTimeLabel
{
maxTime=maxTime+0.1;
timerLabel.text =[NSString stringWithFormat:@"%.1f Seconds",maxTime];
}
Run Code Online (Sandbox Code Playgroud)
这将在Label中显示计时器的值,稍后我可以将maxTime用作Timer停止的时间...
问题是它运行非常不准确.
有没有一种方法可以确保NSTimer严格每0.1秒严格发射一次?我知道NSTimer不准确,我要求进行调整以使其准确.
谢谢