title: How to reload, and reset the number of rows in a UIPickerView - Swift
body: <p>I have a custom picker view, that I need to occupy with elements from an array that I retrieve from parse. However, because the number of elements in the picker are defined before the array is retrieved from parse, the picker wheel displays as empty. How can I reload the contents, and the number of rows in the picker view? Here is my code:</p>
  
  <pre><code>var dates = [String]() 
  var locations = [String]() 
  
  @IBOutlet weak var myPicker: UIPickerView!
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      // Do any additional setup after loading the view.
      var query = PFUser.query()
      query.getObjectInBackgroundWithId(PFUser.currentUser().objectId) { (object: PFObject!, error: NSError!) -&gt; Void in
          self.dates = object["userLocationsDate"] as [String]
          self.locations = object["userLocationsCity"] as [String]
      }
  
     myPicker.reloadAllComponents()
  
  }
  func numberOfComponentsInPickerView(pickerView: UIPickerView) -&gt; Int {
      return 1
  }
  
  func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -&gt; Int {
  
      return dates.count
  
  }
  
  func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -&gt; String! {
  
      return dates[row]    
  }
  </code></pre>