Search code examples
iosobjective-cafnetworkingafnetworking-2

AFNetworking - re-trying until API responds correctly


I'm using an API which returns a key "status" which can either be "completed" or "not completed". I have to to keep asking it until it is "completed". I want to be able to keep requesting the response until I get:

{
  "status": "completed"
}

Is there a way to do this with AFNetworking? Where I can set a maximum number of requests, and a time interval between requests.


Solution

  • I don't believe so. You will need to maintain your own timer to trigger the checks and invalidate the timer once the success status you're waiting for is seen.