title: Unable to open downloaded pdf path in iOS swift?
body: <p>i am trying to implement pdf download option once user tap on download option pdf file should be downloaded and get open. I tried following link but its not working
   <a href="https://stackoverflow.com/questions/29479812/saving-pdf-files-with-swift-in-ios-and-display-them">Saving PDF Files with Swift in iOS and display them</a> and I tried following code. In response its showing Path I gone through with that path but I didn't find any file.</p>
  
  <pre><code> @objc func downloadPdfFile(_ sender : UIButton)
      {
          var localDic :NSDictionary!
          localDic = totalSyllabusArray.object(at: sender.tag) as! NSDictionary
          let filepath = localDic["filepath"] as! String
          let pdfURLString:String = FETCH_InMegh_Image_BaseURL + filepath
          let documentsUrl:URL =  FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first as URL!
          let destinationFileUrl = documentsUrl.appendingPathComponent("downloadedFile.pdf")
          //Create URL to the source file you want to download
          let fileURL = URL(string: pdfURLString)
          let sessionConfig = URLSessionConfiguration.default
          let session = URLSession(configuration: sessionConfig)
          let request = URLRequest(url:fileURL!)
          let task = session.downloadTask(with: request) { (tempLocalUrl, response, error) in
              if let tempLocalUrl = tempLocalUrl, error == nil {
                  // Success
                  if let statusCode = (response as? HTTPURLResponse)?.statusCode {
                      print("Successfully downloaded. Status code: \(statusCode)")
                  }
                  do {
                      try FileManager.default.copyItem(at: tempLocalUrl, to: destinationFileUrl)
                  } catch (let writeError) {
                      print("Error creating a file \(destinationFileUrl) : \(writeError)")
                  }
              } else {
                  print("Error took place while downloading a file. Error description: %@", error?.localizedDescription);
              }
          }
          task.resume()
      }
  </code></pre>