title: Can Swift return value from an async Void-returning block?
body: <p>I want to create a function to check if user_id is already in my database. </p>
  
  <pre><code>class func checkIfUserExsits(uid:String) -&gt; Bool {
      userRef.childByAppendingPath(uid).observeSingleEventOfType(.Value, withBlock: { (snapShot: FDataSnapshot!) -&gt; Void in
                  if snapShot.value is NSNull {
                      return false
                  } else {
                      return true
                  }
      })
  }
  </code></pre>
  
  <p>However, <code>observeSingleEventOfType</code> is a API provided by 3rd party Firebase. It is defined to return <code>Void</code>.  </p>
  
  <blockquote>
    <ul>
    <li>(void)observeSingleEventOfType:(FEventType)eventType withBlock:(void ( ^ ) ( FDataSnapshot *snapshot ))block</li>
    </ul>
  </blockquote>
  
  <p>Error: <code>Type 'Void' does not conform to protocol 'BooleanLiteralConvertible'</code></p>
  
  <p>Appreciate any kind of helps.</p>
  
  <hr>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I am trying a different way:</p>
  
  <pre><code>class func checkIfExist(uid: String) -&gt; Bool {
      var answer:Bool = false
      var text:String = "not yet completed"
      let queue = dispatch_group_create()
      dispatch_group_enter(queue)
          userRef.childByAppendingPath(uid).observeSingleEventOfType(.Value, withBlock: { (snapShot: FDataSnapshot!) -&gt; Void in
                  if snapShot.value is NSNull {
                      text = "This is a new user"
                      answer  = false
                      dispatch_group_leave(queue)
                  } else {
                      text = "Found the user in Firebase"
                      answer = true
                      dispatch_group_leave(queue)
                  }
          })
      dispatch_group_wait(queue, DISPATCH_TIME_FOREVER)
      println(text)
      return answer
  }
  </code></pre>
  
  <p>Somehow it just freeze there. I know this approach could be off-topic now. But please help.</p>