The UIDatePicker
has a property called countDownDuration
so you should be able to use
int seconds = (int)datePicker.countDownDuration;
Edit: to address concern in the comment, make sure to manually set either the countDownDuration
or the time of the datePicker in order to get a "whole-minute" value. For instance, in viewDidLoad
you could set:
datePicker.countDownDuration = 60.0f;
and then the default-selected time duration in your countdown would be exactly 0 hours, 1 minute. Otherwise, by default the date picker will use the current date/time and setting your countdown timer could result in countDownDuration
being up to +59 seconds (e.g. 1 minute could ready anywhere from 60-119, 2 minutes from 120-179, etc) based on the time when you run your app.