我在 Xcode 中收到警告,提示我正在使用的变量未被使用:
- (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]];
}
}
报告未使用的变量是interval
。
为什么interval
被报告为未使用?
最佳答案
它对我来说很好用。尝试清理代码并使用shift commond B进行分析。 -- AV
关于objective-c - 实际使用变量时未使用的变量警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8582890/