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?
How to set a timer for a string to trigger periodically?
118 Views Asked by Pablo Coranta At
2
There are 2 best solutions below
2
Carrione
On
In case when users don't quit app you can use Timer. However, this is only expected for short intervals.
let minute = 60
let anotherTimeInterval = 2 * minute
var timer = Timer.scheduledTimer(timeInterval: minute, target: self, selector: #selector(updateTimer), userInfo: nil, repeats: false)
@objc func updateTimer() {
// do something
timer.invalidate()
timer = Timer.scheduledTimer(timeInterval: anotherTimeInterval, target: self, selector: #selector(updateTimer), userInfo: nil, repeats: false)
}
Normally, you need to prepare a specific data source for a specific day. For example, in your case, you can add a flag or date to each card and use that flag or date to add that card to the data source on a specific date.
Related Questions in SWIFT
- Navigate after logged in with webservice
- URLSession requesting JSON array from server not working
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- Protect OpenAI key using Firebase function
- How to correct error: "Cannot convert value of type 'MyType.Type' to expected argument type 'Binding<MyType>'"?
- How to share metadata of an audio url file to a WhatsApp conversation with friends
- Using @Bindable with a Observable type in SwiftUI
- How to make a scroll view of 9 images in a forEach loop open on image 6 if image 6 is clicked on from a grid?
- Using MTLPixelFormat.rgba16Float results in random round-off errors
- Search and highlight text of current text in PDFKit Swift
- How is passing a function as a parameter related to escaping autoclosure?
- Actionable notification api call not working in background
- Custom layout occupies all horizontal space
- Is it possible to fix slow CKAsset loading on Cloudkit?
- Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value - MapView.isMyLocationEnabled
Related Questions in TIME
- I need help to understand the time wich my simple ''hello world'' is taking to execute
- What would be the most efficient way to store multiple sets of fixed arrays (std::vector)?
- C++ : Is there an objective universal way to compare the speed of iterative algorithms?
- (React)At rendering, initial value of zustand comesout firstly Please, give me your opinions
- Time not correct in "Device explorer" (device manager ; android studio)
- Countdown to varying payday in Javascript
- Time Limit Exceeded, Leetcode problem, 3Sum, 308 / 313 testcases passed, Why is it slow? Python
- Print time stamp in c
- TIMESTAMP Field - UTC <> Local TimeZone
- How to carry Last 24 hours value in time filter from one dashboard to another dashboard in Splunk
- Is there a way to get daylight savings time info for non local timezones
- Can I print '1' n times without using a loop in C programming?
- Embedded Linux board using a GPIO-PPS (without GPS, etc.) for time conditioning - ppstest can SEE the signal and report, but no time conditioning
- Converting streamlit library time input to milliseconds since epoch
- latest version of redshift with crazy compile times
Related Questions in TIMER
- DateTimePicker not working, textField not updating with selected hours and minutes
- Timer stops the program before it is over
- I cannot get this to redirect. The timer works but it doesn't go anywhere. I need this to redirect to another webpage
- Enabling one timer using another
- iOS Swift Timer sometimes fires much later than expected
- Canceling stop the animation made with requestAnimationFrame()
- How to dynamically change fields in blocs flutter
- How to show countdown for all angular pages without resetting
- Problems with function called by System.Threading.Timer
- Angular 17 does not update view using setInterval with NG0500 error in console
- How to time how long a bash alias took to execute (solved... maybe?)
- I'm using JSF and after a timer expires, I want to display a warning
- Under the swiftUI framework, the timer cannot continue to count in the background
- requestAnimationFrame not working when callback not utilised directly
- Crash on Timer Callback in Swift: closure #1 in ViewController.updateTimer() Causes App to Crash
Related Questions in SWIFTUI
- Navigate after logged in with webservice
- When using onDrag in SwiftUI on Mac how can I detect when the dragged object has been released anywhere?
- ScrollView with multiple LazyVGrids jumping around when using .scrollPosition
- How to correct error: "Cannot convert value of type 'MyType.Type' to expected argument type 'Binding<MyType>'"?
- Using @Bindable with a Observable type in SwiftUI
- How to make a scroll view of 9 images in a forEach loop open on image 6 if image 6 is clicked on from a grid?
- Hide LiveActivityIntent Button from Shortcuts App
- Accessibility : Full keyboard access with scroll view in swiftui
- Custom layout occupies all horizontal space
- Detect Tab View drag gesture
- Lazy loading of dependent relationship in SwiftData
- How do a create a reusable simple custom list style with my own color and spacing
- Why/how does a SwiftUI view's identity depend on the value of its `@StateObject` member variable?
- Sheet binded item doesn't deinitialize SwiftUI
- Realm Swift - collection changes listener in SwiftUI
Related Questions in PERIODICITY
- Identifying row numbers where value is stable before and after the value in the column hits a specified value
- Reuse a variable used in Build periodically with parameters in Build periodically with parameters box itself
- decompose timeseries including NAs
- Spliting of overlapping date intervals
- How can one determine the period of a single element of a dataset?
- What is the longest period/shortest frequency that can be reliably recovered using the Lomb-Scargle periodogram?
- Auto-correlation-like algorithm for detecting periods in non-numeric data?
- How can I filter a table for the field values on the last(highest) date in a custom four week period, using DAX in Power BI?
- Extract data values at a higher frequency than time stamps
- how to handle non-periodic timeseries in bfast (R)
- Why do simulated arrival times from a Poisson distribution seem to show periodicity?
- 2.5d line plot for periodic data in Python
- Interpretation of Wald test in modelling periodic data (cosinor package)
- how to force a long function to run with a cyclic check?
- Get Dates that match a periodicity and get number of sequence
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
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
Dateswhen the User uses the Flashcard app.Also, you will need to learn how to use
DateComponents(). Here's a great resource.