I have a List
view that the user can add items.The basic idea I wanted to achieve is; "After 24 hours, reset the list to an empty state./ Delete all the items in the list after 24 hours."
I want this list to be empty after 24 hours. Perhaps the app could check the time the user first accessed the app and see if 24 hours have passed since then. Alternatively, the app may check the current date and see if it has changed.
I usually use the code below to check if the list is empty or not:
if items.count == 0
This is how I show the items in the List view:
List { ListRowItemView(item: item) }
I thought about adding an onAppear
action to the List
view since I think that it is not possible to refresh the app in the background if the app is not opened or etc.
But I don't know how to create a 24 hours countdown that will set the items.count
to 0
I would appreciate the help!