カウントダウン タイマーが機能しません。画面の「99」で始まり、そこで止まります。まったく動かない。
私のヘッダーファイルで。
@interface FirstTabController : UIViewController {
NSTimer *myTimer;
}
@property (nonatomic, retain) NSTimer *myTimer;
私の.mファイルで
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context {
myTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countDown) userInfo:nil repeats:YES];
}
- (void)countDown {
int counterInt = 100;
int newTime = counterInt - 1;
lblCountdown.text = [NSString stringWithFormat:@"%d", newTime];
}
そして、dealloc で「myTimer」を無効にします。だから、誰かが私のコードのどこが悪いのか教えてもらえますか?