RunMode is already considering timeout. RunMode has also return value. "NO if the run loop could not be started"

This can be shorten to something like:
while(!condition() && [mainLoop runMode:NSDefaultRunLoopMode beforeDate:timeOut]);