Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift3 调度组:检查有多少个“调度组”;“输入”;_Swift3_Grand Central Dispatch - Fatal编程技术网

Swift3 调度组:检查有多少个“调度组”;“输入”;

Swift3 调度组:检查有多少个“调度组”;“输入”;,swift3,grand-central-dispatch,Swift3,Grand Central Dispatch,我使用swift3DispatchGroup来等待多个异步操作完成(根据这些操作可以完美地工作,并且符合预期) 有没有办法检查已经输入了多少操作,比如dispatchGroup.count或类似的东西?没有,什么都没有。您需要自己平衡enter()和leave(),而不进行计数 您可以在调试说明中看到组的输入计数: 操作系统调度组:组[0x60000221d950]={xref=3,ref=3, 计数=2,gen=0,waiters=0,notifs=1} 并从中提取int值: let coun

我使用swift3
DispatchGroup
来等待多个异步操作完成(根据这些操作可以完美地工作,并且符合预期)


有没有办法检查已经输入了多少操作,比如
dispatchGroup.count
或类似的东西?

没有,什么都没有。您需要自己平衡
enter()
leave()
,而不进行计数


您可以在调试说明中看到组的输入计数:

操作系统调度组:组[0x60000221d950]={xref=3,ref=3, 计数=2,gen=0,waiters=0,notifs=1}

并从中提取int值:

let count = dispatchGroup.debugDescription.components(separatedBy: ",").filter({$0.contains("count")}).first?.components(separatedBy: CharacterSet.decimalDigits.inverted).compactMap{Int($0)}.first

这是硬核,但赞成尝试。:)由于使用了dispatchGroup的debugDescription,此代码在“发布版本配置”中工作吗???。我可以获得“离开”计数吗?计数器是否有模拟值?