我编写了以下代码来运行NSTimer
。但是 NSTimer 选择器没有被调用。
.h 文件
@interface XViewController : UIViewController {
NSTimer *repeatServerRequest;
}
@property(nonatomic, retain) NSTimer *repeatServerRequest;
- (void)checkForMinimunOnetimePinEntry;
- (void) initializeTimer;
- (void)stopTimer;
.m 文件
@synthesize repeatServerRequest;
- (void)checkForMinimunOnetimePinEntry {
// some code
}
- (void) initializeTimer {
repeatServerRequest = [NSTimer scheduledTimerWithTimeInterval:15.0
target:self
selector:@selector(checkForMinimunOnetimePinEntry)
userInfo:nil
repeats:YES];
}
- (void)stopTimer {
[repeatServerRequest invalidate];
[repeatServerRequest release];
repeatServerRequest = nil;
// [self.repeatServerRequest invalidate];
// [self.repeatServerRequest release];
// self.repeatServerRequest = nil;
}
我究竟做错了什么?
还回答我哪一个是正确的使用:self.repeatServerRequest 或只是 repeatServerRequest? 提前致谢!