Skip to content

Instantly share code, notes, and snippets.

@billibala
Created October 10, 2013 10:51
Show Gist options
  • Save billibala/6916556 to your computer and use it in GitHub Desktop.
Save billibala/6916556 to your computer and use it in GitHub Desktop.
Call "waitForCompletion" after invoking an async method. Upon receiving notification, set "executionDate" to YES and call [runloopExpirationTimer fire]. This will "dry up" the fake run loop.
- (void)waitForCompletion {
runloopExpirationTimer = [NSTimer scheduledTimerWithTimeInterval:600.0 target:self selector:@selector(dumbTimerMethod:) userInfo:nil repeats:NO];
while ( !executionDone ) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
}
}
- (void)dumbTimerMethod:(NSTimer *)theTimer {
runloopExpirationTimer = nil;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment