I have to run a countdown timer for a specific interval but how to feed self.startDate in this function
- (void)updateCounter:(NSTimer *)theTimer {
NSDate *now = [NSDate date];
// has the target time passed?
if ([self.startDate earlierDate:now] == self.startDate) {
[theTimer invalidate];
} else {
NSUInteger flags = NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents *components = [[NSCalendar currentCalendar] components:flags fromDate:now toDate:self.startDate options:0];
NSLog(@"there are %d hours, %d minutes and %d seconds remaining", [components hour], [components minute], [components second]);
}
}