title: How to use completion handler correctly
body: <p>I understand how completion handlers work, but im a bit confused on the syntax. Below is a function that, given a username, calls a parse query to find out the corresponding userId. The query ends after the function is returned (so it returns nil), which is why we need the completion handler. How do i implement it?</p>
  
  <pre><code>func getUserIdFromUsername(username: String) -&gt; String {
      var returnValue = String()
      let query = PFQuery(className: "_User")
      query.whereKey("username", equalTo: username)
      query.findObjectsInBackgroundWithBlock { (objects, error) -&gt; Void in
          if let objects = objects {
              for object in objects {
                  returnValue = object.objectId!
              }
          }
      }
      return returnValue
  
  }
  </code></pre>
  
  <p>NOTE: I know examples similar to this exist, but they are either not swift, or extremely lengthy. This is a short and concise version that contains Parse.</p>