This feature has not yet been implemented, although I think they are working on it. I also had to do something like this:
semaphore = dispatch_semaphore_create(0); [myObject myFunctionWithCallback:^(BOOL success){ if(success) dispatch_semaphore_signal(semaphore); else STFail(@"Call failed"); dispatch_semaphore_signal(semaphore); }]; [self waitForSemaphore];
With the wait function, something like this:
- (void)waitForSemaphore; { float step_duration = .1; float wait_steps = 2 / step_duration; while (dispatch_semaphore_wait(semaphore, dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC / 10)) && wait_steps > 0){ CFRunLoopRunInMode(kCFRunLoopDefaultMode,step_duration, YES); wait_steps--; } if (wait_steps <= 0) { STFail(@"Timeout!"); }
}
source share