I have two parallel & independent functions named function a() ->Bool & function b() ->Bool
Now If any of this function fails I want to show alert box
Note: I can not put one function into another. both func can take ~5 second to complete
Tried approach: created two flag inside a() & b() named var aCompleted: Bool var bCompleted
&
func showAlert() {
if aCompleted && bCompleted {
// show UIAlertController....
}
I am looking for better approach, Please guide.
2
Answers
Easiest approach would be to use Dispatch Groups.
The .notify function is called only when both the functions have been executed.