title: Swift write an async/await method with return value
body: <p>I want to write an async-await method with a return value, but my code doesn't work. I also tried another way such as <code>DispatchQueue.global</code> <code>DispatchGroup()</code> and so on. 
  <br>Here is my code:<br></p>
  
  <pre><code>func checkPassCode() -&gt; Bool {
  
          var result = false
  
          let closure = { (_ flag:Bool) -&gt; Void in
              result = flag
          }
  
          if var pin = self.keychain.get("pin") {
              let userPin = self.pin.joined(separator: "")
              let encryptedData = NSData(base64Encoded: pin, options: [])
  
              AsymmetricCryptoManager.sharedInstance.decryptMessageWithPrivateKey(encryptedData! as Data) { (success, result, error) -&gt; Void in
                  if success {
                      pin = result!
                      print("userPin is: \(userPin)")
                      print("storePin is: \(pin)")
                      closure(userPin == pin)
                  } else {
                      print("Error decoding base64 string: \(String(describing: error))")
                      closure(false)
                  }
              }
          }
          return result
      }
  </code></pre>