Search code examples
objective-ciosnstimer

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


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


Solution

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

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