使用GCD的完成区块 [英] Completion block using GCD

查看:93
本文介绍了使用GCD的完成区块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个需要完成块和障碍"功能的应用程序. 据我所知,NSOperation API具有completionBlock属性,而GCD API具有dispatch_barrier_(a)sync函数来处理障碍需求.

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应该具有您需要的所有内容.只需为您的工作单位使用dispatch_group_async/dispatch_group_enter,然后为您的完成处理程序派遣dispatch_group_notify.

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.

这篇关于使用GCD的完成区块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆