1
我有一个使我的计时器无效的问题。NSTimer不会使无效
@property (nonatomic, strong) NSTimer *timer;
里面我对成功的块,我分配和设置我的计时器在主线程:
dispatch_async(dispatch_get_main_queue(), ^{
self.timer = [NSTimer scheduledTimerWithTimeInterval:[Config refreshInterval].integerValue target:self selector:@selector(methodThatHasABlockCalledMentionedAbove) userInfo:nil repeats:NO];
});
在我textFieldDidBeginEditing
我无效我的计时器是这样的:
dispatch_async(dispatch_get_main_queue(), ^{
[self.timer invalidate];
self.timer = nil;
});
我的方法仍然在定时器上执行。有什么收获?
检查,如果当你调用调度异步self.timer不是零... 'assert(self.timer)' –
我查过了。这不是零 – Flipper
你是否可以设置几个计时器对象而不会使旧的无效? –