@IBOutlet weak var Datetime: UITextField!
let datePicker = UIDatePicker()
func createDatePicker()
{
let toolbar = UIToolbar()
toolbar.sizeToFit()
let doneButton = UIBarButtonItem(barButtonSystemItem: .done, target:nil,action: #selector(donePressed))
toolbar.setItems([doneButton], animated: false)
Datetime.inputAccessoryView = toolbar
Datetime.inputView = datePicker
}
newEvent.setValue(formater.stringFromDate(Datetime), forKey: "eventDateTime")
嘿伙计们,我通过日期选择器在文本字段中获取日期和时间。我可以将其提交给核心数据