title: How can i return value from async block?
body: <p>This is the function I want to return value from but I know I am doing fool thing to return value from a closure that I used in from a library and it returns void, I think it is async void block, I am new in it please help. :(</p>
  
  <pre><code>   func xmlRequest(_ id:Int) -&gt; String{
              var array1:Array&lt;Any&gt; = Array&lt;Any&gt;();
              array1.append("body" as Any);
              array1.append("date" as Any);
              array1.append("author_id" as Any);
  
              let con:NSDictionary = NSDictionary();
              var field2:Array&lt;Any&gt; = Array&lt;Any&gt;();
              field2.append([["id", "=", [id]]]);
              let url = Login.BASEURL+XMLRPC_SERVICE_OBJECT;
              let param3 = [Login.DATABASE, Login.LOGIN_ID, Login.PASSWORD, "mail.tracking.value","search_read",field2,con] as [Any];
              AlamofireXMLRPC.request(url, methodName: "execute_kw", parameters: param3).responseXMLRPC { (response: DataResponse&lt;XMLRPCNode&gt;) in
                  switch response.result {
                  case .success(let value):
                      return "success";
                  case .failure(let error):
                      return error;
                  }//switch end
              }
          }
  </code></pre>
  
  <p>Here are the errors that I got if I try to return value. 
  <a href="https://i.stack.imgur.com/AgevW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AgevW.png" alt="enter image description here"></a></p>
  
  <pre><code>func xmlRequest(_ id:Int) -&gt; String{
          var array1:Array&lt;Any&gt; = Array&lt;Any&gt;();
          array1.append("body" as Any);
          array1.append("date" as Any);
          array1.append("author_id" as Any);
  
          let con:NSDictionary = NSDictionary();
          var field2:Array&lt;Any&gt; = Array&lt;Any&gt;();
          field2.append([["id", "=", [id]]]);
          let url = Login.BASEURL+XMLRPC_SERVICE_OBJECT;
          let param3 = [Login.DATABASE, Login.LOGIN_ID, Login.PASSWORD, "mail.tracking.value","search_read",field2,con] as [Any];
          var valueToReturn:String = "default"
          AlamofireXMLRPC.request(url, methodName: "execute_kw", parameters: param3).responseXMLRPC { (response: DataResponse&lt;XMLRPCNode&gt;) in
              switch response.result {
              case .success(let value):
                  valueToReturn = "success"
              case .failure(let error):
                  valueToReturn = "error"
              }//switch end
          }
          return valueToReturn;
      }
  </code></pre>
  
  <p>I also try this hack, but it always return default, because of grant central dispatch kind of thing working inside it, i again say i am new in ios please help in :( </p>