james
james

Reputation: 26271

unused variable warning when variable is actually being used

I am given a warning in Xcode that a variable I am using, is not being used:

- (void)timerTicked:(id)sender {
  [timerButton setTitle:[self timerIsActive] ? @"Stop timer" : @"Start Timer" forState:UIControlStateNormal];
  if([self timerIsActive]) {
    NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:timeEntry.startDate];
    double seconds = (int) interval % 60;
    double minutes = (int) interval / 60.0;
    double hours = (int) interval / 60.0 / 60.0;

    [timerLabel setText:[NSString stringWithFormat:@"%.0f hours %.0f minutes %.0f seconds", hours, minutes, seconds]];
  }
}

The variable reported not being used is interval.

Why is interval being reported as unused?

Upvotes: 0

Views: 715

Answers (1)

AAV
AAV

Reputation: 3803

It works fine for me. Try to clean the code and Analyze using shift commond B. -- AV

Upvotes: 1

Related Questions