I'm working on a project in which the user can select a time interval (HH:mm) from a UIDatePicker
in count down mode and, with that time interval, I want to trigger a notification.
I created the UIDatePicker
in the Storyboard and set the Mode to Count Down Timer in the Attributes Inspector.
The problem is that when I get the current value of the datePicker, the value is never correct.
For example, if the user selects 1 minute, I get random values between 70 an 110 but never 60! How is this possibile? (The problem occurs with every selection)
This is how I get the current value:
timePicker.countDownDuration
and for testing purpose, I print it with
timePicker.countDownDuration.description
Maybe there is a bug or something that I don't know? (of course there is)
I tried to convert the value represented on the UIDatePicker
in string a then, reconvert it in TimeInterval
but if there is a better method it would be great.
Ok problem solved, maybe it's a bug of XCode.
The problem occurs when you build the datepicker
from storyboard and set it's mode paramether to Count Down Timer
.
To solve this problem, simply don't set the mode of the datepicker
on count down timer
from the storyboard but you need to set the mode programmatically with
timepicker.datePickerMode = .countDownTimer
Doing this, the problem is solved