title: Save files from iOS share extension for use by host app
body: <p>I'm working on an app extension which I would like to allow users to share various files with the host app.</p>
  
  <p>Example: Pick photo, choose share via app, photo is saved to shared folder &amp; then available when user next opens host app.</p>
  
  <p>I have the host app ready to read from the shared folder and the extension set up with just images for now, but the bit I'm stuck at is to retrieve the file data (blob or path I'm not sure?) and then write it to the shared folder.</p>
  
  <p>Here is the relevant section from the extension:</p>
  
  <pre><code> override func didSelectPost() {
      let content = extensionContext!.inputItems[0] as NSExtensionItem
      for attachment in content.attachments as [NSItemProvider] {
  
          // Image attachment
          if attachment.hasItemConformingToTypeIdentifier(kUTTypeImage as String) {
              // save this to file in shared folder for host app to retrieve...
          }
  
      }
  
      self.extensionContext!.completeRequestReturningItems([], completionHandler: nil)
  }
  </code></pre>
  
  <p>I've looked at many other questions but can't seem to find anything that fits my use case.</p>