title: I can't set the time in a date picker in xcode
body: <p>I have made the following window in Xcode:</p>
  <p><a href="https://i.stack.imgur.com/U96pY.jpg" rel="nofollow noreferrer">Window for logging assingments</a></p>
  <p>And I have written this to go along with that window</p>
  <pre><code>class logHomeworkViewController: UIViewController {
      
      @IBOutlet var dueDatePicker: UIDatePicker!
      @IBOutlet var promptDatePicker: UIDatePicker!
      @IBOutlet weak var homeWorkName: UITextField!
      override func viewDidLoad() {
          super.viewDidLoad()
          let today = Date()
          homeWorkName.addTarget(self, action: #selector(nameChanged), for: .editingChanged)
          dueDatePicker.date = Calendar.current.date(byAdding: .day, value: 1,to: today)!
          var dateComponents = DateComponents()
          
          //set min date to midnight
          dateComponents.hour=0
          dateComponents.minute = 24
          dateComponents.day = Calendar.current.component(.day, from: today)
          dateComponents.month = Calendar.current.component(.year, from: today)
          dueDatePicker.minimumDate = Calendar.current.date(from: dateComponents)
          // Do any additional setup after loading the view.
      }
      //once due date has been chosen, allow the user to set up a reminder date
      @IBAction func dueDateChanged(_ sender: Any) {
          promptDatePicker.maximumDate = Calendar.current.date(byAdding: .hour, value: -1, to: dueDatePicker.date)
          promptDatePicker.minimumDate = Calendar.current.date(byAdding: .hour, value: 1, to: Date())
          promptDatePicker.isEnabled = true
      }
      
      //once a assingment name has been set, allow input of a due date
      @objc func nameChanged(_ textField: UITextField){
          if(homeWorkName.text! != &quot;&quot;){
              dueDatePicker.isEnabled = true
          }else{
              dueDatePicker.isEnabled = false
          }
      }
  
  }
  </code></pre>
  <p>I intend to guide the user through this window from top to bottom. As in one field has been entered the next opens up for input. Upon testing, I found that when I try to open up the date picker and set the time <strong>after setting the assignment name</strong>, it crashes. The logs display this after the crash <code>unrecognized selector sent to instance 0x7fdabb623520 terminating with uncaught exception of type NSException</code>. Keep in mind I'm using the style of the compact date picker. This error does not occur with any another style but I need this one to work as it is best suited for my needs. This only applies to the actual time field not am or pm.</p>
  <p><a href="https://i.stack.imgur.com/kShA2.jpg" rel="nofollow noreferrer">Time entry field</a></p>
  <p>I have narrowed down the error to the line <code>dueDatePicker.isEnabled = true</code>. When I leave the first date picker enabled by default in my storyboard and comment out the <code>nameChanged()</code> function, I get no error when attempting to set the time. I have tried to hide it instead of disabling the view but that does not work either and results in the same error. What may I have done to cause this and how can I solve it?</p>