Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine if day change has occurred

I would like to create a notifciation that occurs every time a new day has occurred locally (either while using the app, or if it occurs in between launches). I was wondering what might be the best way to go about observing this change.

like image 308
minimalpop Avatar asked Nov 04 '11 21:11

minimalpop


3 Answers

While your app is running, you can listen for the UIApplicationSignificantTimeChangeNotification notification and test the current day when you receive that. When your app quits, you can save the current day to your preferences, and when the app launches again, you can test the saved day against the current day.

You can get information about the current day using NSDateComponents.

like image 150
Lily Ballard Avatar answered Oct 26 '22 04:10

Lily Ballard


As mentioned in the other thread, as of iOS8, you can also directly listen to NSCalendarDayChangedNotification.

like image 7
camimvogelsang Avatar answered Oct 26 '22 04:10

camimvogelsang


Check out : Erica Sadun Time Utililties

There are some useful methods there for checking dates.

Alternatively you can look at UILocalNotifcations

You could schedule a local notification with a repeatInterval of one day.

It all depends on what you want to do but those are some options.

like image 1
Jeff Avatar answered Oct 26 '22 03:10

Jeff