Created
May 18, 2015 12:05
-
-
Save NeoTeo/ca062a80b645f13397d8 to your computer and use it in GitHub Desktop.
Wait for async call using semaphores.
This file contains hidden or 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
| let sema = dispatch_semaphore_create(0) | |
| dispatch_async(dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0), ^{ | |
| // Do async stuff | |
| // When finished, signal to continue below. | |
| dispatch_semaphore_signal(sema) | |
| } | |
| // Wait for the load to complete. | |
| dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment