NSTimer scheduledTimerWithTimeInterval:target:selector:userInfo:repeats doesn't invoke the method

aneuryzm picture aneuryzm · Jul 16, 2012 · Viewed 15.2k times · Source

The timer never invokes the method. What am I doing wrong ? This is the code:

NSTimer *manualOverlayTimer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(hideManual) userInfo:nil repeats:NO];

method:

-(void)hideManual

thanks

Answer

aneuryzm picture aneuryzm · Jul 17, 2012

It was a thread issue. I've fixed with:

dispatch_async(dispatch_get_main_queue(), ^{
    // Timer here
});