title: How to return a value from a void closure in Swift?
body: <p>I have a function that queries a certain user in order to access an array of that user. I returns the user and I can access their array. However, the call is asynchronous and what is being returned is nil. The function over all has a completion handler, however, inside there is a query call and by default that query returns Void.</p>
  
  <pre><code>    func _getAllMatches(completionHandler: ((UIBackgroundFetchResult) -&gt; Void)!) -&gt; Int{
      var toReturn = [GTLUserUser]()
      let query = GTLQueryUser.queryForUserList()
      query.userBucket = "messages-20-messagestabletes-1465782960"
      service.executeQuery(query, completionHandler: {(ticket, response, error) -&gt; Void in
          if error != nil{
              self._showErrorDialog(error)
              return
          }
          else{
              let userCollection = response as! GTLUserCollection
              if let newUsers = userCollection.items() as? [GTLUserUser]{
                  toReturn = newUsers
                  completionHandler(UIBackgroundFetchResult.NewData)
  
              }
          }
      })
  
  return toReturn[0].likedArray.count
  }
  </code></pre>
  
  <p>How do I wait for this query to return and assign to "toReturn" so that it will actually return something instead of returning nothing.</p>