From 1122074ce47dca056c18dea2ff810927756c6858 Mon Sep 17 00:00:00 2001 From: iamank1t Date: Tue, 17 Apr 2018 16:50:27 +0530 Subject: [PATCH] alert added to show confirmation to users when their Id Card successfully saved in photos --- mySteemitIdCard/IDcardVC.swift | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mySteemitIdCard/IDcardVC.swift b/mySteemitIdCard/IDcardVC.swift index 900ac29..76db65b 100644 --- a/mySteemitIdCard/IDcardVC.swift +++ b/mySteemitIdCard/IDcardVC.swift @@ -64,7 +64,7 @@ class IDcardVC: UIViewController { let image = imageWithView(view: self.mainView) //Then save your ID Card image - UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil) + UIImageWriteToSavedPhotosAlbum(image, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil) } //function to convert the ID Card UIView into an UIImage @@ -76,4 +76,19 @@ class IDcardVC: UIViewController { return image! } + // function to show users alert, if image saved or not + @objc func image(_ image: UIImage, didFinishSavingWithError error: Error?, contextInfo: UnsafeRawPointer) { + if let error = error { + // we got back an 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: "Yureka!", message: "Your Steem Id Card has been saved to your photos.", preferredStyle: .alert) + ac.addAction(UIAlertAction(title: "Great", style: .default)) + present(ac, animated: true) + } + } + + }