title: Pulling data from parse in swift as an array
body: <p>I have a list of competitions in a class on parse named "Competitions", and I need to pull the list of competitions from said class to populate an array to populate a UI PickerView. What is the easiest way possible to complete this?</p>
  
  <p>Thank you.</p>
  
  <p>//edit with code</p>
  
  <pre><code>    override func viewDidLoad() {
      super.viewDidLoad()
      var compQuery = PFQuery(className:"Competitions")
      compQuery.whereKey("teamID", equalTo:"1")
      compQuery.findObjectsInBackgroundWithBlock {
          (competitions: [AnyObject]!, error: NSError!) -&gt; Void in
          if error == nil {
              // Do something with the found objects
              for competition in competitions {
                  NSLog("%@", competition["compName"] as String)
                  self.competitionArray += [competition["compName"] as String]
              }
          } else {
              // Log details of the failure
              NSLog("Error: %@ %@", error, error.userInfo!)
          }
      }
  }
  </code></pre>
  
  <p>// Edited with new errors
  Since I am adding the objects to a UIPicker for the user to select a value, I used this to get the objects as an array of strings, </p>
  
  <pre><code>var competitionArrayString:Array = [competitionArray as AnyObject as [String]]
  </code></pre>
  
  <p>however I am receiving the error that my class does not have the member "competitionArray"</p>
  
  <pre><code>import UIKit
  import Swift
  import Parse
  
  class CompetitionViewController: UIViewController  {
  var competitionArrayString:Array = [""]
  var competitionArray:NSMutableArray = []
  
  override func viewDidLoad() {
      super.viewDidLoad()
      var compQuery = PFQuery(className:"Competitions")
      compQuery.whereKey("teamID", equalTo:"1")
  
      self.competitionArray = NSMutableArray()
  
      compQuery.findObjectsInBackgroundWithBlock {
          (competitions: [AnyObject]!, error: NSError!) -&gt; Void in
          if error == nil {
              // Do something with the found objects
              for competition in competitions {
                  NSLog("%@", competition["compName"] as String)
                  self.competitionArray.addObject([competition["compName"] as String])
              }
          } else {
              // Log details of the failure
              NSLog("Error: %@ %@", error, error.userInfo!)
          }
      }
  }
  
  var competitionArrayString:Array = [competitionArray as AnyObject as [String]]
  
  func numberOfComponentsInPickerView(pickerView: UIPickerView) -&gt; Int {
      return 1
  }
  
  
  func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -&gt; Int {
      return competitionArrayString.count
  }
  
  
  func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -&gt; String! {
      return competitionArrayString[row]
  }
  
  func pickerView(pickerView: UIPickerView!, didSelectRow row: Int, inComponent component: Int)
  {
      var selectedData = competitionArrayString[row]
      var userDefaults = NSUserDefaults.standardUserDefaults()
      userDefaults.setValue(selectedData, forKey: "competitionData");
      userDefaults.synchronize();
  
      println("You Selected: \(selectedData)")
  
  
  }
  
  }
  </code></pre>