title: iOS/Swift: What is the difference to share PDF file/data via UIActivityViewController
body: <p>I am loading pdf data from remote url and display them in WKWebView. </p>
  
  <p>Now I am adding sharing functionality and I am considering what is the difference to share this downloaded data as <strong>Data</strong> and as <strong>File</strong> stored in /tmp location on disk. </p>
  
  <p>It seems that both ways works </p>
  
  <p>A)</p>
  
  <ol>
  <li>get Data</li>
  <li>create UIActivityViewController with activityItems: [pdfData]</li>
  </ol>
  
  <p>B) </p>
  
  <ol>
  <li>get Data </li>
  <li>save Data in /tmp directory </li>
  <li>get URL to tmp file</li>
  <li><p>create UIActivityViewController with activityItems: [pdfFileUrl]</p>
  
  <pre><code>private func sharePDFData(from barButtonItem: UIBarButtonItem) {
      guard let pdfData = self.pdfData else { return }
      let activityViewController = UIActivityViewController(activityItems: [pdfData], applicationActivities: nil)
      activityViewController.popoverPresentationController?.barButtonItem = barButtonItem
      activityViewController.popoverPresentationController?.permittedArrowDirections = .up
      self.present(activityViewController, animated: true, completion: nil)
  }
  </code></pre></li>
  </ol>
  
  <p>And</p>
  
  <pre><code>      private func sharePDFFile(from barButtonItem: UIBarButtonItem) {
          guard let pdfFileUrl = self.pdfTempFileUrl() else { return }
          print("PDF temp file url:", pdfFileUrl)
  
          if FileManager.default.fileExists(atPath: pdfFileUrl.path) {
  
              let activityViewController = UIActivityViewController(activityItems: [pdfFileUrl], applicationActivities: nil)
              activityViewController.popoverPresentationController?.barButtonItem = barButtonItem
              activityViewController.popoverPresentationController?.permittedArrowDirections = .up
              self.present(activityViewController, animated: true, completion: nil)
          }
      }
  </code></pre>
  
  <p>The only difference I can see is that using temporary file storage I can change filename of the shared PDF document.  </p>