问题
I am developing an app that requires a completion block and a "barrier" functionality.
As far as I know, NSOperation
API has a completionBlock
property and GCD API has the dispatch_barrier_(a)sync
function to handle the barrier needs.
What should I do in order to accomplish both of the needs? Thanks!
回答1:
dispatch_group should have all the pieces you need. Just dispatch_group_async/dispatch_group_enter for your work units, then dispatch_group_notify for your completion handler.
来源:https://stackoverflow.com/questions/13788873/completion-block-using-gcd