xcodemacosnstimernsthreadnsbutton

NSPopButton Stops NSTimer on main thread during selection


I have multiple timers that working on the main thread.
And I have a NSPopButton.
And I experience a bad behavior, timers just don't work, starting from the point that the use open the pop button's menu until he close the menu.
Any Ideas?


Solution

  • This is probably because your NSTimer is running on the UI thread. You should run it on another thread like so:

    NSTimer *myTimer = …
    [[NSRunLoop mainRunLoop] addTimer:myTimer forMode:NSRunLoopCommonModes];