Created
November 5, 2012 20:11
-
-
Save endoze/4020065 to your computer and use it in GitHub Desktop.
Async Unit Testing Helper Method
This file contains 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
# found at http://www.infinite-loop.dk/blog/2011/04/unittesting-asynchronous-network-access/ | |
- (BOOL)waitForCompletion:(NSTimeInterval)timeoutSecs { | |
NSDate *timeoutDate = [NSDate dateWithTimeIntervalSinceNow:timeoutSecs]; | |
do { | |
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:timeoutDate]; | |
if([timeoutDate timeIntervalSinceNow] < 0.0) | |
break; | |
} while (!done); | |
return done; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment