Looping with a delay in Swift

Coming from JavaScript and Python, creating a delay in Swift was odd. Here’s how to get your delays working.

Photo by Fabio Fistarol on Unsplash
  • Provide reminder at set time intervals until stopped by the user or the data is not available
  • Provide reminders for multiple loops of the timer without any API call
  • Repeat until stopped by user or data isn’t available
Photo by NeONBRAND on Unsplash
  • If the API call is successful; call the function containing the Timer and do whatever else you need to do with the data.
  • Let the Timer loop until it meets it’s condition providing feedback on each loop as if there has been another API call, invalidate it, and then call the function with the API call again.

Software engineer from Liverpool, UK. Enjoy front-end development, especially app development.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store