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!
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.