I have got some dates for some events and their ascending order from the database .
Now , I want want some buttons ..
in this structure …
–######## Last Week #####—-
–######## yesterday #####—-
–######## today #####—-
–######## tomorrow #####—-
–######## Next Week #####—-
Now when I press the respected buttons ..
the events in that respected duration should be shown up ..
I mean all the data should be compared with today and all the data should be shorted by this order..
can anyone give me a idea or logic for this ?
The best way to deal with dates is by using NSDateComponents.
for example, to get the date for tomorrow use:
So, what you need to do is:
When you push a button, build a predicate to retrieve only the objects between the two dates. For example, getting all the objects in the “tomorrow” category:
You can use a small convenient method for getting the dates, by adding a category to NSDate with this method:
And use this method like this: