Created
March 30, 2015 19:04
-
-
Save manmal/754e59acbe61517023bd to your computer and use it in GitHub Desktop.
asyncWaitFor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BOOL asyncWaitFor(BOOL *flag, NSTimeInterval timeout) { | |
NSDate *timeoutDate = [NSDate dateWithTimeIntervalSinceNow:timeout]; | |
do { | |
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:timeoutDate]; | |
if ([timeoutDate timeIntervalSinceNow] < 0.0) { | |
break; | |
} | |
} | |
while (!*flag); | |
return *flag; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment