-2

So I made an app using swift and swift ui and need to get the next item in an array, retrieved from firebase, every day. Think of it like how the Wordle site gets a new word every day at a certain time. I looked everywhere for how to accomplish this, but it simply didn't exist.

Nexteon
  • 39
  • 6
  • Welcome to SO - Please take the [tour](https://stackoverflow.com/tour) and read [How to Ask](https://stackoverflow.com/help/how-to-ask) to improve, edit and format your questions. Without a [Minimal Reproducible Example](https://stackoverflow.com/help/minimal-reproducible-example) it is impossible to help you troubleshoot. What part of your code isn't working? What part do you need help troubleshooting? It sounds like you are asking for someone to just provide a solution without showing an attempt to solve it yourself. – lorem ipsum Aug 15 '22 at 11:48
  • The question is pretty vague; there are a variety of [timers](https://stackoverflow.com/search?q=%5Bswift%5Dtimer) and [observers](https://stackoverflow.com/questions/44973888/run-code-at-midnight-everyday/44983918#44983918) in Swift that can notify the app to do a daily task. Other than that, the question needs clarity as there are a LOT of solutions available. – Jay Aug 15 '22 at 17:42

2 Answers2

1

There are many ways to perform a task every day at a certain time in Swift. Here are some of the most common:

  1. Use a timer.

  2. Use an alarm.

  3. Use a calendar.

  4. Use a repeating task.

Ron Adin
  • 49
  • 8
  • Thanks, but for instance with the calendar, how would you exactly check. Would you store the first date in core data, and then check the next time the app is opened if the date is after, then perform the function, and then save that time? – Nexteon Aug 15 '22 at 11:21
1

You can use Firebase schedule functions. Write a function that will be triggered in every 24h. (But not sure if this is included in their free plan). This answer also discusses some alternative options u can use to achieve the above result.

udi
  • 3,672
  • 2
  • 12
  • 33