I am developing an application in which there is this scenario in which I have to make a database entry for a new day each time date changes i.e. time become 00:00 or 12:00 am. I have a method which is responsible to do this but I don't know and can't even find a way to call it when the date changes or when the time turns 00:00. Kindly, help me out if you know any link or if you have any suggestion to do this.
Asked
Active
Viewed 378 times
0
-
http://stackoverflow.com/questions/13324633/nsdate-beginning-of-day-and-end-of-day – xphobia Sep 18 '14 at 02:10
1 Answers
1
Don't have the exact code but I think this can help you :
First of all without background support your app can't make a service call :
Learn about background task here : Background fetch tutorial
Now you can do one thing, get the current time whenever the app launches and find the time till next midnight, then start a timer to fire after that time interval. Hope this helps.
Like this :
[NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(updateNewDate) userInfo:nil repeats:YES];
Here you need to make timeInterval dynamic in accordance to the current time and midnight difference.

ejaz dogar
- 115
- 3
- 13

Ravi_Parmar
- 12,319
- 3
- 25
- 36