如何在没有计时器变量的情况下调用 scheduledTimerWithTimeInterval

how to call scheduledTimerWithTimeInterval without a timer variable

想要删除定时器未被使用的警告...

 timer = [NSTimer scheduledTimerWithTimeInterval:.01 target:self selector:@selector(loadSeries:) userInfo:_response repeats: NO];

我找到了建议使用...的讨论

 NSTimer.scheduledTimerWithTimeInterval(timeInterval: 0.1, target: self, selector: @selector(loadSeries:), userInfo: _response, repeats: false)

然而,returns 错误表明 NSTimer 没有 属性 scheduledTimerWithTimeInterval 并且目标未声明。

找不到任何方法来创建没有悬空计时器变量的计时器。

谢谢,

约翰

而不是

timer = [NSTimer scheduledTimerWithTimeInterval:.01 target:self selector:@selector(loadSeries:) userInfo:_response repeats: NO];

...只需删除作业即可。

[NSTimer scheduledTimerWithTimeInterval:.01 target:self selector:@selector(loadSeries:) userInfo:_response repeats: NO];