我使用Swift 3 DispatchGroup
等待多个异步操作完成(根据this answer完美且符合预期。
有没有办法检查已经输入了多少操作,例如dispatchGroup.count
或类似的操作?
答案 0 :(得分:5)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="EmploymentUpdateRequests">
<xsl:copy>
<xsl:for-each-group select="EmploymentUpdateRequest"
group-by="descendant::FieldValue[@Name ='FORNAMN']">
<xsl:sort select="descendant::FieldValue[@Name ='FORNAMN']/ValidFrom" order="ascending"/>
<xsl:copy-of select="current-group()"/>
</xsl:for-each-group>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
和enter()
,而不必计算。
答案 1 :(得分:5)
您可以在调试说明中看到进入该组的次数:
OS_dispatch_group:group [0x60000221d950] = {xref = 3,ref = 3, count = 2 ,gen = 0,服务员= 0,notif = 1}
并从中提取int值:
let count = dispatchGroup.debugDescription.components(separatedBy: ",").filter({$0.contains("count")}).first?.components(separatedBy: CharacterSet.decimalDigits.inverted).compactMap{Int($0)}.first