title: CompletionHandler with Async call in Swift 3
body: <p>I would like to return an array (<code>arr</code>) from method (with async call). I implement the <code>completionHandler</code> in the method, but I can't use my method to get my array : <code>Cast from '(@escaping ((Array&lt;Any&gt;) -&gt; Void)) -&gt; ()' to unrelated type '[[String : Any]]' always fails</code> </p>
  
  <p>How can I fix this ?</p>
  
  <p>Here is my code :</p>
  
  <pre><code>func dataWithURL(completion: @escaping ((_ result:Array&lt;Any&gt;) -&gt; Void)) {
      let urlString = "https://api.unsplash.com/photos/?client_id=71ad401443f49f22556bb6a31c09d62429323491356d2e829b23f8958fd108c4"
      let url = URL(string: urlString)!
      let urlRequest = URLRequest(url: url)
      let config = URLSessionConfiguration.default
      let session = URLSession(configuration: config)
  
      var arr = [[String:String]]()
      let task = session.dataTask(with: urlRequest, completionHandler: { (data, response, error) in
          // do stuff with response, data &amp; error here
          if let statusesArray = try? JSONSerialization.jsonObject(with: data!, options: .allowFragments) as? [[String: Any]] {
              for item in statusesArray! {
                  let photos = item["urls"] as? [String: Any]
                  let photo = photos?["small"] as? String
                  let myDictionary = [
                      "name": "test",
                      "imageURL": photo]
                  arr.append(myDictionary as! [String : String])
              }
              print(arr)
              completion(arr)
          }
      })
  
      task.resume()
  }
  </code></pre>
  
  <p>And when I want to get my array :</p>
  
  <pre><code>lazy var photos: [Photo] = {
  
      var photos = [Photo]()
  
  // HERE THE ERROR APPEARS
  guard let data = self.dataWithURL as? [[String: Any]] else { return photos }
      for info in data {
          let photo = Photo(info: info)
          photos.append(photo)
      }
      return photos
  }()
  </code></pre>