title: How to properly use selectors in swift 4
body: <p>I have read many tutorials and even the official Apple documentation and must not understand what is wrong with this code.</p>
  
  <pre><code>var dueDatePicker = UIDatePicker()
  
  @IBOutlet weak var textField: UITextField!
  
  override func viewDidLoad() {
      super.viewDidLoad()
      textField.inputView = dueDatePicker
      dueDatePicker.addTarget(self, action: #selector(datePickerValueChanged(_:)), for: UIControlEvents.valueChanged)
  }
  
  func datePickerValueChanged(_ sender: UIDatePicker){
      //Do Stuff
  }
  </code></pre>
  
  <p>At runtime, I click on the textField and the UIDatePicker appears. The function that the selector points to is executed. As soon as I click a UI object outside of the UIDatePicker, the app crashes with this error:</p>
  
  <blockquote>
    <p>Terminating app due to uncaught exception
    'NSInvalidArgumentException', reason: '-[YourApp.PromiseViewController
    dueDateChanged:]: unrecognized selector sent to instance 0x100b12ae0'</p>
  </blockquote>
  
  <p>What I don't understand is that the "selector" or pointer to the desired function is recognized initially. However, when I trigger another event from another UI Object this exception is thrown.</p>
  
  <p>Why is this happening? </p>
  
  <p>Shouldn't this exception be triggered when <code>datePickerValueChanged()</code> is called initially?</p>