title: My function returns empty array in swift and parse
body: <p>HI there I am writing a function to get data from my parse server in swift everything is working alright and the data is getting read well. but when I try to return the array it returns me an empty array.
  I also added a print in the &quot;Get data in background&quot; and there, the array was getting full.So the problem is not getting the data.</p>
  <pre class="lang-swift prettyprint-override"><code>public func getthearray() -&gt; Array&lt;UIImage&gt;
  {
      let user = PFUser.current()
      let array = user?[&quot;Photos&quot;] as! Array&lt;PFFileObject&gt;
      var imagearray = [UIImage]()
  
      for x in array
      {
          x.getDataInBackground
          { (dataa, error) in
  
              var img = UIImage(data: dataa!)
              imagearray.append(img!)
          }
      }
  
      return imagearray
  }
  </code></pre>