Reputation: 605
I need to call an Web API(web service) multiple time with different parameters available in an array. Trying to call API within getting a loop and use Alamofire. It responds properly for initial 3-4 calling. After that it move to failed state.
API call in not interdependent. Appreciated any example.
Upvotes: 1
Views: 412
Reputation: 2328
Maybe you need to use Dispatch Groups:
let dispatchGroup = DispatchGroup()
dispatchGroup.enter()
longRunningFunction { dispatchGroup.leave() }
dispatchGroup.enter()
longRunningFunctionTwo { dispatchGroup.leave() }
dispatchGroup.notify(queue: .main) {
print("Both functions complete 👍")
}
The before code, it's a little example, you can try using similar concepts, insert your function within the loop for example and implement .leave() on each iteration
Upvotes: 1