Skip to content

Instantly share code, notes, and snippets.

@AlexandrFadeev
Created October 2, 2019 06:24
Show Gist options
  • Save AlexandrFadeev/ba4dd443eef6acfff88fb1b1401ffaa5 to your computer and use it in GitHub Desktop.
Save AlexandrFadeev/ba4dd443eef6acfff88fb1b1401ffaa5 to your computer and use it in GitHub Desktop.
Semaphore example in Objective C
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
[object runSomeLongOperationAndDo:^{
// hack hack hack...
dispatch_semaphore_signal(sema);
}];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
dispatch_release(sema);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment