Search code examples
nstimer

how to call scheduledTimerWithTimeInterval without a timer variable


Would like to remove the warning that timer is not being used in...

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

I found a discussion which suggested using...

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

That, howver, returns errors that NSTimer doesnt have the property scheduledTimerWithTimeInterval and that Target is undeclared.

Cannot find any way to create the timer without the dangling timer variable.

Thanks,

John


Solution

  • Instead of

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

    ...just delete the assignment.

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