实际使用变量时未使用的变量警告 [英] unused variable warning when variable is actually being used
本文介绍了实际使用变量时未使用的变量警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Xcode中警告我,我正在使用的变量未被使用:
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]];
}
}
报告未使用的变量为 interval
。
为什么 interval
被报告为未使用?
Why is interval
being reported as unused?
推荐答案
对我来说很好。尝试清除代码并使用公共移位B进行分析。-AV
It works fine for me. Try to clean the code and Analyze using shift commond B. -- AV
这篇关于实际使用变量时未使用的变量警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文