swifttimetimerswiftuiperiodicity

How to set a timer for a string to trigger periodically?


I'm making a FlashCards app and I would like to set a timer for the cards in a way so that if the user knows the answer, the card will trigger again next day, then if he knows it again, it will trigger in 5 days and so on. I haven't found anything related to this, any help with it?


Solution

  • Get track of the Dates and the User's performance with each card. (You can use a Timer here. For instance, if the User 'knows' the answer within a minute, the card will be marked as 'correct' (known), and beyond that time, the card will be marked as 'wrong' (not yet mastered and needs to be repeated).
    Create a logic wherein the cards marked as 'wrong' will popup after a few days or so. I suggest you use CoreData to save the Dates when the User uses the Flashcard app.
    Also, you will need to learn how to use DateComponents(). Here's a great resource.