Im trying to capture date to a variablew outside of funciton but I keep getting this message :
Value of type '(UIDatePicker) -> ()' has no member 'date'
This is the code
var selectedDate: String?
@IBAction func datePicker(_ sender: UIDatePicker) {
selectedDate = self.datePicker.date
}
You are calling the function itself which makes no sense unless there is also an outlet datePicker
.
Use the sender
parameter
@IBAction func datePicker(_ sender: UIDatePicker) {
selectedDate = sender.date
}
and declare selectedDate
as Date
var selectedDate: Date?