I want to download an Image and save it with Timestamp name.
Below is code that I’ve used :
@IBAction func btnDownload_Clicked(_ sender: UIButton) {
let timeStamp = String(Date().ticks)
print("timeStamp : \(timeStamp)")
UIImageWriteToSavedPhotosAlbum(imgQRCode.image!, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)
}
//MARK: - Add image to Library
func image(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) {
if let error = error {
let objAlert = UIAlertController(title: "Error", message: error.localizedDescription, preferredStyle: .alert)
objAlert.addAction(UIAlertAction(title: "OK", style: .default))
present(objAlert, animated: true)
}
else {
let objAlert = UIAlertController(title: "", message: saveQR, preferredStyle: .alert)
objAlert.addAction(UIAlertAction(title: "OK", style: .default))
present(objAlert, animated: true)
}
}
However, the issue with above code is that how to set Timestamp as name for Image?
I’ve tried this link wherein image is downloaded by not visible in Photos app.
Any quick fix?