The following code causes a crash every time I save a date using the date-picker. The new date is saved, but not before XCode terminating. There's something wrong with my "DatePickerValueChanged" Please tell me why this isn't working:
Code:
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
tableView.estimatedRowHeight = tableView.rowHeight
tableView.rowHeight = UITableViewAutomaticDimension
//hide blank cells in table view
let backgroundView = UIView(frame: CGRectZero)
tableView.tableFooterView = backgroundView
let addButton = UIBarButtonItem(barButtonSystemItem: .Add, target: self, action: "addNewTask")
self.navigationItem.rightBarButtonItem = addButton
setupUIElements()
datePicker.addTarget(self, action: "datePickerValueChanged", forControlEvents: UIControlEvents.ValueChanged)
}
Function:
@IBOutlet weak var datePicker: UIDatePicker!
@IBAction func datePickerValueChanged(sender: UIDatePicker) {
saveTHeCourseWork("dueDate", value: sender.date) // selected date value is saved as the value for "dueDate"
}
Error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Program4.DetailViewController datePickerValueChanged]: unrecognized selector sent to instance 0x7fce737baa40