title: How can I populate a picker view depending on the selection of another picker view in Swift?
body: <p>Looking for a solution to populate a picker view depending on the selection of another picker view within the same view controller.
  The first selects a category. The second the items of that category.</p>
  
  <p>Here's what I (Swift beginner) came up with:</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController, UIPickerViewDataSource,      UIPickerViewDelegate {
  
  var countryClasses = ["US", "EU", "JP"]
  var usItems = ["usitem1", "usitem2", "usitem3", "usitem4", "usitem5"]
  var euItems = ["euitem1", "euitem2", "euitem3", "euitem4", "euitem5"]
  var jpItems = ["jpitem1", "jpitem2", "jpitem3", "jpitem4", "jpitem5"]
  
  @IBOutlet weak var countryPicker: UIPickerView!
  
  @IBOutlet weak var itemPicker: UIPickerView!
  
  override func viewDidLoad() {
      super.viewDidLoad()
      self.countryPicker.dataSource = self;
      self.countryPicker.delegate = self;
      self.itemPicker.dataSource = self;
      self.itemPicker.delegate = self;
  }
  
  func numberOfComponentsInPickerView(pickerView: UIPickerView) -&gt; Int {
      return 1
  }
  
  func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -&gt; Int {
      return countryClasses.count
  }
  
  func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -&gt; String! {
      return countryClasses[row]
  }
  </code></pre>
  
  <p>}</p>