Вопрос

I've added a timer with the runloopmode NSEventTrackingRunLoopMode like so:

NSRunLoop *runLoop = [NSRunLoop currentRunLoop];

NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:0.50
                                                  target:self
                                                selector:@selector(targetMethod:)
                                                userInfo:nil
                                                 repeats:YES];


[runLoop addTimer:timer forMode:NSEventTrackingRunLoopMode];

I thought this would only execute whilst for example a menu is open (modal), but it triggers the entire time, even when doing nothing. Is this the normal behavior?

Это было полезно?

Решение

Yes, this is normal behaviour. You add a timer to the runloopMode which is used for tracking events. This runloop runs all the time and is used to determine if there are events that needs to be processed and passed to your event handlers.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top