run-loop

Do Cocoa applications have a main loop?

On Linux under X11 and using GTK+ you have something called "Main Loop". Once you start the main loop you have a timer that runs in the main thread of the application. You can set that timer to a callback function and you have a very nice application-wide timer. This is sample code for that: GMainLoop *loop; if(!loop_running) { ...

How to block until certain notification is posted in Cocoa?

What's the best way to sleep/wait until certain notification is posted? I've got class with asynchronous API that gets data from NSNotification (notification comes from Cocoa, I can't avoid it) and I need to unit test it. So far I've figured out semi-busy wait: [[NSRunLoop mainRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow...