Skip to content

Instantly share code, notes, and snippets.

@albertodebortoli
Last active January 4, 2016 16:09
Show Gist options
  • Select an option

  • Save albertodebortoli/8645930 to your computer and use it in GitHub Desktop.

Select an option

Save albertodebortoli/8645930 to your computer and use it in GitHub Desktop.
Macro to test asynchronous Objective-C code
#define FutureConditionToBreakWithTimeout(_condition_, _duration_) \
NSDate *loopUntil = [NSDate dateWithTimeIntervalSinceNow:_duration_]; \
while (!_condition_ && [loopUntil timeIntervalSinceNow] > 0) { \
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:loopUntil]; \
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment