I am finding it hard to save date when app loads for the first time and compare it with new date when the user runs the app the next day.
I can easily get current date using following and format it the way I want:
var currentDate = Date()
This will save the date in currentDate variable. But when the user comes back tomorrow the currentDate will have tomorrow’s date. How can I have the currentDate, once assigned, does not change by itself. Any suggestions what I am doing is wrong.
Thanks in advance.
you need to save the date alongside the data, then compare the date from the data from the previous date
think of it as a tag
Do you have any code snippet to demonstrate?
sorry i dont have one. but it should be like
daytoday > myData.date
being myData is the data from your database (per row)
Look for a series of four articles on the web. I can’t remember the author. The first is titled How to work with dates and times in Swift 3, part 1: Dates, Calendars, and DateComponents. Yeah, it says Swift 3, but it will teach you all there is to know about date and time handling.
There are many like these. Can you please send me the link to the document you are talking about. Thanks
Thank you. I will check out shortly.