Skip to content

Instantly share code, notes, and snippets.

@manmal
Created March 30, 2015 19:04
Show Gist options
  • Save manmal/754e59acbe61517023bd to your computer and use it in GitHub Desktop.
Save manmal/754e59acbe61517023bd to your computer and use it in GitHub Desktop.
asyncWaitFor
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