dispatch_group_leave crash in swift dispatch_group_leave crash in swift ios ios

dispatch_group_leave crash in swift


If dispatch_group_leave call isn't balanced with dispatch_group_enter then crash may happen.


In the worst case, you can check the discount group's count via its debugDescription String:

let count = self.groupExecuting.debugDescription.components(separatedBy: ",").filter({$0.contains("count")}).first!.components(separatedBy: CharacterSet.decimalDigits.inverted).filter({Int($0) != nil})assert(count.first != "0")

This strategy is further explored in this question: DispatchGroup: check how many "entered"