It will keep counting down and updating the current time. Anyone has any idea how to approach this problem? I don't see how the NStimer will recognize the date format like this: 20110803 23:59:59
Look up NSDateFormatter. You can specify a format string (-[setDateFormat:])that lets you convert to AND from NSDate and NSString.
When converting back to your countdown view, you may want to use NSDateComponents and NSCalendar to get the pieces you need for your countdown label (instead of NSDateFormatter). You could do something like:
NSDateComponents *countdown = [[NSCalendar currentCalendar]
components:(NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit)
fromDate:[NSDate date]
toDate:expiration
options:0];
This will calculate all the unit differences for you (with respect to the device's currently configured calendar settings).
You can get the components back with a call like [countdown day] or [countdown hour].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With