Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- [self scheduleCheckTimer];
- }
- -(void) scheduleCheckTimer
- {
- [self.timer invalidate];
- self.timer = [NSTimer scheduledTimerWithTimeInterval: [self.checkDate timeIntervalSinceNow] target: self selector: @selector(checkTimerTimeout) userInfo: nil repeats: NO];
- }
- -(void) checkTimerTimeout
- {
- [[UIApplication sharedApplication] cancelAllLocalNotifications];
- [self scheduleCheckTimer];
- }
- -(NSDate*) nextCheckDate {
- NSCalendar *gregorian = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease];
- NSDateComponents* dateComponents = [gregorian components: kCFCalendarUnitEra |
- kCFCalendarUnitYear |
- kCFCalendarUnitMonth |
- kCFCalendarUnitDay |
- kCFCalendarUnitHour |
- kCFCalendarUnitMinute |
- kCFCalendarUnitSecond fromDate: [NSDate date]];
- dateComponents.hour = 0;
- dateComponents.minute = 0;
- dateComponents.second = 0;
- dateComponents.day = dateComponents.day + 1;
- return [gregorian dateFromComponents: dateComponents];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement