I had issues with this and I haven't found a proper answer on SO so I'll leave a small tutorial here.
The goal is to filter fetched objects by today's date.
Note: It's Swift 3 compatible.
I had issues with this and I haven't found a proper answer on SO so I'll leave a small tutorial here.
The goal is to filter fetched objects by today's date.
Note: It's Swift 3 compatible.
You can't simply use to compare your date to today's date:
It will show you nothing since it's unlikely that your date is the EXACT comparison date (it includes seconds & milliseconds too)
The solution is this:
It's by far the easiest & shortest way of showing only objects which have today's date.
In swift4, Lawrence413's can be simplify a bit:
It get rid of the
component
part, makes the code have better readability.