I want to make Network Requests inside a while loop and check if the result satisfies a condition. If condition is not satisfied, I want to continue running the while loop and again make Network Request and so on..
What I am trying to do is: Pseudo code:
while true{
// Run Network Req and get Result
// Check a Condition using Result
// If Condition is met: return using completion Handler
// If Condition is not met, continue with the While loop
}
My try:
while true{
// Run Network Req and get Result
request(){ response in
switch response{
case .success (let res){
// Check a Condition using Result
if(res.count == 10){
// If Condition is met: return using completion Handler
completionHandler(res)
}
else{
// If Condition is not met, continue with the While loop
**// 1. HOW TO CONTINUE THE LOOP?**
}
}
case .failure{
completionHandler(error)
}
}
}
**// 2. HOW TO WAIT TILL LOOP IS CONTINUED?**
}