You can use an NSTimer
. There is a repeats
parameters in the NSTimer scheduleWithTimeInterval to do repeating request.
Instead you can also define a method you can call every 20 seconds and in that method you can decide whether to make the request based on some logic(like a boolean) whether the previous request was successful or not. This can be useful, if there is a server problem and you continue requesting the server unnecessarily.