title: Returning data from URLSession and saving in property variable
body: <p>I try to get some data from server using <strong><em>URLSession.shared.dataTask</em></strong>.
  It works fine, but I can't save result like a class variable. 
  Many answers recommend to use <strong><em>completion Handler</em></strong>, but it doesn't help for my task. </p>
  
  <p>Here is my testing code:</p>
  
  <pre><code>class PostForData {
  func forData(completion:  @escaping (String) -&gt; ()) {
      if let url = URL(string: "http://odnakrov.info/MyWebService/api/test.php") {
          var request = URLRequest(url: url)
          request.httpMethod = "POST"
          let postString : String = "json={\"Ivan Bolgov\":\"050-062-0769\"}"
          print(postString)
          request.httpBody = postString.data(using: .utf8)
          let task = URLSession.shared.dataTask(with: request) {
              data, response, error in
              let json = String(data: data!, encoding: String.Encoding.utf8)!
                  completion(json)
          }
          task.resume()
      }
  }
  }
  class ViewController: UIViewController {
  var str:String?
  override func viewDidLoad() {
      super.viewDidLoad()
      let pfd = PostForData()
  
      pfd.forData { jsonString in
          print(jsonString)
          DispatchQueue.main.async {
              self.str = jsonString
          }
      }
      print(str ?? "not init yet")
  }
  }
  </code></pre>