title: UIImageWriteToSavedPhotosAlbum not working
body: <p>I am generating barcode from a string and then try to save this image to iPhone photos library. Here is my code:</p>
  
  <pre><code>@IBOutlet weak var uuidLabel: UILabel!
  @IBOutlet weak var barcodeDisplay: UIImageView!
  
  @IBAction func generateBarcode(_ sender: Any) {
      barcodeDisplay.image = generateBarcodeFromString(string: uuidLabel.text!)
      UIImageWriteToSavedPhotosAlbum(barcodeDisplay.image!, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)
  }
  
  @objc func image(_ image: UIImage, didFinishSavingWithError error: NSError?, contextInfo: UnsafeRawPointer) {
      if let error = error {
          let ac = UIAlertController(title: "Save error", message: error.localizedDescription, preferredStyle: .alert)
          ac.addAction(UIAlertAction(title: "OK", style: .default))
          present(ac, animated: true)
      } else {
          let ac = UIAlertController(title: "Saved!", message: "Your image has been saved to your photos.", preferredStyle: .alert)
          ac.addAction(UIAlertAction(title: "OK", style: .default))
          present(ac, animated: true)
      }
  }
  
  func generateBarcodeFromString(string:String)-&gt;UIImage? {
      let data = string.data(using: String.Encoding.ascii)
      if let filter = CIFilter(name: "CICode128BarcodeGenerator") {
          filter.setValue(data, forKey: "inputMessage")
          let transform = CGAffineTransform(scaleX: 1, y: 1)
          if let output = filter.outputImage?.transformed(by: transform) {
              return UIImage(ciImage: output)
          }
      }
      return nil
  }
  </code></pre>
  
  <p>When i run this app, it's generate the barcode and it's displayed on the view controller. When i try to save this image to iPhone photos library, the selector says,"Your image has been saved to your photos." but image is not saved into iPhone photos library.</p>
  
  <p>After that, when i try to convert this image into NSData by following:</p>
  
  <pre><code>let data = UIImagePNGRepresentation(barcodeDisplay.image!) as NSData?
  </code></pre>
  
  <p>It's return nil. What's the problem behind this ?</p>