UIDatePicker
uses the target-action pattern, so when you create one, you have to use addTarget(_:action:for:)
to assign one of your functions that will get called.
So if you have this function:
@objc
private func userSelectedDate(_ sender: UIDatePicker) {
//sender.date would contain the date selected by the user
}
you would set it up like this:
//I use ViewController here but you would use whatever
//your UIViewController is actually named
datePicker.addTarget(self,
action: #selector(ViewController.userSelectedDate),
for: .valueChanged)