对于“secondsLeft”和小时、分钟和秒的“未使用变量”,我有一个“本地声明隐藏实例变量”错误。提前感谢您对此提供的任何帮助。
.h 文件
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "BT_viewController.h"
@interface BT_screen_blank : BT_viewController {
NSTimer *timer;
IBOutlet UILabel *myCounterLabel;
}
@property (nonatomic, retain) UILabel *myCounterLabel;
@property (nonatomic) int secondsLeft;
@property (nonatomic) int minutes;
@property (nonatomic) int hours;
@property (nonatomic) int seconds;
-(void)updateCounter:(NSTimer *)theTimer;
-(void)countdownTimer;
@end
.m 文件
@implementation BT_screen_blank
@synthesize myCounterLabel;
@synthesize secondsLeft, hours, minutes, seconds;
//viewDidLoad
-(void)viewDidLoad{
[BT_debugger showIt:self:@"viewDidLoad"];
[super viewDidLoad];
int hours, minutes, seconds;
int secondsLeft;
secondsLeft = 16925;
[self countdownTimer];
}
- (void)updateCounter:(NSTimer *)theTimer {
if(secondsLeft > 0 ){
secondsLeft -- ;
hours = secondsLeft / 3600;
minutes = (secondsLeft % 3600) / 60;
seconds = (secondsLeft %3600) % 60;
myCounterLabel.text = [NSString stringWithFormat:@"%02d:%02d:%02d", hours, minutes, seconds];
}
else{
secondsLeft = 16925;
}
}