title: Cannot set UIPickerView dataSource / delegate programmatically
body: <p>I have a UIPickerView that I've placed on my story board and created a reference to the picker in my controller. In my controller, I would like to set the delegate programmatically. Here is what I've tried:</p>
  
  <pre><code>class MyViewController: UIViewController {
      @IBOutlet weak var text1: UITextField!
      @IBOutlet weak var text2: UITextField!
      @IBOutlet weak var picker: UIPickerView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          let textPickerDelegate = TextPickerdDelegate(text1: text1, text2: text2, picker: picker)
  
          text1.delegate = textPickerDelegate
          text2.delegate = textPickerDelegate
  
          picker.delegate = textPickerDelegate
          picker.dataSource = textPickerDelegate
          picker.hidden = true
      }
  }
  </code></pre>
  
  <p>The code for the delegate looks like this:</p>
  
  <pre><code>class TextPickerDelegate: NSObject, UIPickerViewDelegate, UIPickerViewDataSource, UITextFieldDelegate {
      static let TEXT_1_DATA: Array&lt;Array&lt;String&gt;&gt; = {
          let text1Data: Array&lt;Array&lt;String&gt;&gt; = [[], ["a", "b"]]
          for i in 1...100 {
              var text1 = text1Data[0] as Array&lt;String&gt;
              text1.append(String(i))
          }
          return text1Data
      }()
  
      static let TEXT_2_DATA: Array&lt;Array&lt;String&gt;&gt; = {
          let text2Data: Array&lt;Array&lt;String&gt;&gt; = [[], ["c", "d"]]
          for i in 1...100 {
              var text2 = text2Data[0] as Array&lt;String&gt;
              text2.append(String(i))
          }
          return text2Data
      }()
  
      let text1: UITextField
      let text2: UITextField
      let picker: UIPickerView
  
      var pickerData: Array&lt;Array&lt;String&gt;&gt; = TextPickerDelegate.TEXT_1_DATA
  
      init(text1: UITextField, text2: UITextField, picker: UIPickerView) {
          self.text1 = text1
          self.text2 = text2
          self.picker = picker
      }
  
      func numberOfComponentsInPickerView(pickerView: UIPickerView) -&gt; Int {
          return pickerData.count
      }
  
      func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -&gt; Int {
          return pickerData[component].count
      }
  
      func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -&gt; String! {
          return pickerData[component][row]
      }
  
      func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
          // Select the row
          picker.hidden = true;
      }
  
      func textFieldShouldBeginEditing(textField: UITextField) -&gt; Bool {
          if (textField == text1) {
              pickerData = TextPickerDelegate.TEXT_1_DATA
          } else if (textField == text2) {
              pickerData = TextPickerDelegate.TEXT_2_DATA
          }
  
          picker.hidden = false
          return false
      }
  }
  </code></pre>
  
  <p>As soon as I try to render the view containing the picker, I get the following error:</p>
  
  <pre><code>2015-08-20 20:19:14.840 MyApp[13642:645025] -[_UIAppearanceCustomizableClassInfo numberOfComponentsInPickerView:]: unrecognized selector sent to instance 0x7fe072d64ba0
  </code></pre>