UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Alamofire: Recursion inside of request?

Forums > Swift

There is an external hardware device which sends its status to an httpserver, I get that data from the httpserver and process it.

Sometimes the hardware devices sends "I'm not ready" for for 3 to 15 seconds and will then send new status of "I'm ready"

session.request(IP:String, method: .get, parameters: queryItems)
      .validate()
      .responseString { response in
      switch response.result {
          case .success:
            deviceStatus = response.description
              if deviceStatus == "I'm ready" 
              { 
              //update UI 
              }else {
              //"I'm not ready"
              //device is not ready, do I recurse here?
              }

          case let .failure(error):
            print(error.localizedDescription)
        }

How do I set up the recusion until the device is "I'm ready"? Should I wrap the requestion func inside of completion handlers?

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.