I am sending two async calls at the same time and want to perform another task when getting result from both APIs...
One of the APIs is actually used to upload the video which can take time ... the task may complete even after the app comes from the background or maybe reopen after being terminated by the user (I re-upload the video if the last result was not successful)...
I want to perform some action when both APIs got successful results...
Previously I was using DispatchGroup()
but I didn't find it a much effective solution since the app got crashed if you call group.leave()
one extra time after calling group.enter()
. User can check for the count
before leaving the group with following line:
self.group.debugDescription.components(separatedBy: ",").filter({$0.contains("count")}).first!.components(separatedBy:CharacterSet.decimalDigits.inverted).filter({Int($0) != nil})
but this is overkill for such a small task that's why I am trying to find some better solution for such tasks.