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:10]]
without processing of run loop notifications aren't received. But how can I break from run loop immediately when desired notification comes?