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.
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.