1

I'm working on an application, There are several NSWindows in this application and one StatusItem in order to access any of NSWindows when they are not open. Some of these windows continuously updating their interface with new numbers and statuses. The problem is whenever I'm clicking the StatusItem in the System Status Bar it's blocking the updates on the windows and I can't see any updates until I close the StatusMenu.

1 Answer 1

3

This is about Run Loop Modes.

Deferred operations that run on the main thread are typically scheduled for NSDefaultRunLoopMode of the main run loop which means to not run when a menu or a modal dialog is open. You need to use NSRunLoopCommonModes instead, which will allow them to run in both default and event tracking (menus, dialogs) modes.

For example:

  • if you are using NSTimer to fire update events, instead of scheduledTimerWithTimeInterval, use timerWithTimeInterval in combination with [[NSRunLoop currentRunLoop] addTimer:theTimer forMode:NSRunLoopCommonModes].

  • if you are using performSelectorOnMainThread:withObject:waitUntilDone:, instead use performSelectorOnMainThread:withObject:waitUntilDone:modes:, passing [NSArray arrayWithObject:NSRunLoopCommonModes] for the modes: argument.

2
  • Thank you for your answer. Since most of my app code is written, is there a way to apply NSRunLoopCommonModes to selectors without going through this process or somehow changing the StatusMenu runloop mode?
    – Abcd Efg
    Jan 10, 2013 at 16:49
  • @AbcdEfg I'm afraid no. There is no way to let status menu run in other mode, you have to change the way you schedule timers and selectors. Jan 10, 2013 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.