限制Swift中的webservice调用次数

时间:2017-03-01 15:51:40

标签: ios grand-central-dispatch

我需要做很多网络服务电话 - 下载图片 - 但是想要将它限制为5同时建立连接。我需要concurrent queue还是应该使用dispatch group

我认为我需要一个队列,但只有当Web服务响应返回时才会删除队列中的项目。

1 个答案:

答案 0 :(得分:0)

答案取决于你想要达到的目标。

如果您希望在继续之前等待所有答案,则应使用dispatch_group,但如果您希望在每次WS响应后执行操作(如更新UI),则需要concurrent queue