 					} else if propertyChange.name == "brand" {
 						self?.brandTextField.text = (propertyChange.newValue as! String)
 					} else if propertyChange.name == "expirationDate" {
-						let newDate = propertyChange.newValue as! Date?
+						let newDate: Date?
+						if let changedDate = propertyChange.newValue as? Date {
+							newDate = changedDate
+						} else {
+							newDate = nil
+						}
 						self?.setExpirationDateText(with: newDate)
 					} else if propertyChange.name == "price" {
 						

			}
		} else if textField == expirationDateTextField {
			let date: Date?
			if let expDateString = expirationDateTextField.text {
				date = dateFormatter!.date(from: expDateString)
			} else {
				date = nil

		super.viewWillDisappear(animated)
		
		notificationToken?.stop()
	}
}

extension ProductViewController {
	func expirationDateChanged(_ sender: UIDatePicker) {
		let datePicker = expirationDateTextField.inputView! as! UIDatePicker
		let expirationDate = datePicker.date
		setExpirationDateText(with: expirationDate)
	}
}

