title: How to connect pickerviews and labels in iOS?
body: <p>I have two <code>pickerView</code> and two <code>Label</code> on my <code>ViewController</code>.</p>
  
  <p>The question is how I could connect <code>label</code>s to <code>pickerView</code>'s data array (string type) and show in <code>label</code>s chosen pickerView cell?</p>
  
  <pre><code>@IBOutlet weak var valuetype1: UILabel!
  
      var pickerData: [String] = [String]()
  
  
   override func viewDidLoad() {
          super.viewDidLoad()
  
          self.picker1.delegate = self
          self.picker1.dataSource = self
          self.picker2.delegate = self
          self.picker2.dataSource = self
  
          pickerData = ["Годы", "Месяцы", "Недели", "Дни", "Часы", "Минуты"]
  }
  
  func numberOfComponents(in pickerView: UIPickerView) -&gt; Int {
      return 1
  }
  
  
  func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -&gt; Int {
      return pickerData.count
  }
  
  
  func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -&gt; String? {
      return pickerData[row]
  }
  
  func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
      valuetype1.text = pickerData[row]
      valuetype2.text = pickerData[row]
  }
  </code></pre>
  
  <p>How could you see I connected labels (<code>valuetype(1..2)</code>) to <code>pickerData</code> but it always show in both <code>label</code>s one String. I need to show in first <code>label</code> String chosen in <code>pickerView1</code> and another string in second <code>label</code>, chosen in <code>pickerView2</code>.</p>