title: get empty array when calling a parse data retrieve - swift
body: <p>I have a function in my xcode project in which I'd like to use some data that are on bitnami parse server.</p>
  
  <p>In that function I'm creating a string array which I'd like to load up with my cloumn loc_names in classname Plocations.</p>
  
  <p>My problem is when I calling this function above in my viewDidLoad() I get an empty array. How is that possible?</p>
  
  <p>I was thinking about some kind of thread handling but I'm not sure.</p>
  
  <pre><code>func getParseLox() -&gt; [String]{
      var locName = ""
      var locNames = [String]()
  
      let query = PFQuery(className: "Plocations")
  
      query.selectKeys(["loc_names"])
      query.findObjectsInBackground { (objects, error) -&gt; Void in
          if let objects = objects {
              for item in objects {
                  var anyu = item.object(forKey: "loc_names") as! String
  
                  print("anyu type:", type(of: anyu) )
                  print("anyu: ", anyu)
  
                  locNames.append(anyu)
  
                  print("locnames: ", locNames)
                  print("item: ", item.object(forKey: "locName") as! String)
              }
  
              locName = objects[0].object(forKey: "locName") as! String
              print("these are the selectedKeys ", locName)
          }
      }
  
      print("locNames array: ", locNames)
  
      return locNames
  }
  </code></pre>