I have a UIDatePicker
, which I print the selected date as per the code below. However, it doesn't print the selected date, only the current date.
@objc func setupDiscoverButton() {
let cell = Bundle.main.loadNibNamed("FirstTableViewCell", owner: self, options: nil)?.first as! FirstTableViewCell
// Date
let sessionDate = cell.datePicker.date
print("date: \(sessionDate)")
}
This is where I make definitions for my UIDatePicker
.
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = Bundle.main.loadNibNamed("FirstTableViewCell", owner: self, options: nil)?.first as! FirstTableViewCell
// Date & time picker
cell.datePicker.minimumDate = Date()
cell.datePicker.timeZone = TimeZone.current
// Discover button
cell.discoverButton.addTarget(self, action: #selector(setupDiscoverButton), for: .touchUpInside)
return cell
}