title: Save image to library from URL, rename, and share it using Swift
body: <p>I want to share images to Instagram from my own iOS app and I am using Kingfisher throughout the project to download and cache images and show them in UIImageViews but this time I want to do something a little bit different. </p>
  
  <p>Basically, I am getting a response from an API with the url of an image and I want to</p>
  
  <ol>
  <li><strong>Download the image to the library using the URL</strong></li>
  </ol>
  
  <p>There is a bunch of questions on this for objective-C using </p>
  
  <pre><code> UIImageWriteToSavedPhotosAlbum 
  </code></pre>
  
  <p>but I am using Swift.</p>
  
  <ol start="2">
  <li><strong>Rename it with .igo extension (instagram exclusive)</strong></li>
  </ol>
  
  <p>Not sure how to go about this, would depend on number 1.</p>
  
  <ol start="3">
  <li><p><strong>Then I could share it doing something like</strong></p>
  
  <pre><code>        let image = UIImage(named: "downloadedImage")
          let objectsToShare: [AnyObject] = [ image! ]
          let activityViewController = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
          activityViewController.popoverPresentationController?.sourceView = self.view
  
  
          activityViewController.excludedActivityTypes = [ UIActivityTypeAirDrop, UIActivityTypePostToFacebook ]
  
  
          self.presentViewController(activityViewController, animated: true, completion: nil)
  </code></pre></li>
  </ol>
  
  <p><strong>or I could do it using the instagram hooks:</strong></p>
  
  <pre><code> instagram://library?LocalIdentifier=\(localID)
  </code></pre>
  
  <p>Documentation on this is scarce specially for Swift. How can I go about this? a push in the right direction is all I need.</p>