I have a problem invalidating my timer.
@property (nonatomic, strong) NSTimer *timer;
Inside my block on success, I am allocating and setting my timer on main thread:
dispatch_async(dispatch_get_main_queue(), ^{
self.timer = [NSTimer scheduledTimerWithTimeInterval:[Config refreshInterval].integerValue target:self selector:@selector(methodThatHasABlockCalledMentionedAbove) userInfo:nil repeats:NO];
});
At my textFieldDidBeginEditing
I am invalidating my timer like this:
dispatch_async(dispatch_get_main_queue(), ^{
[self.timer invalidate];
self.timer = nil;
});
My method still gets executed on timer. What's the catch?