Completion block using GCD

喜夏-厌秋 提交于 2019-12-25 07:31:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!