vendredi 28 avril 2017

how to add flag to prevent app from crashing (swift3)

I have a button that saves a photo. The problem is a photo has to be in imageView for the save function to work. How can I add a flag in this code. So if the image view is blank. Just an error message will pop up and my app will not crash.

    @IBAction func Saverton(_ sender: Any) {

        guard let croppedImage = cropImageIntoQuarterSquare(image: image2!),
            let combinedImage = saveImage(image1: image1!, image2: croppedImage, image3: croppedImage) else {
                // handle the error
                return
        }

        UIImageWriteToSavedPhotosAlbum(combinedImage, self, #selector(image(_:didFinishSavingWithError:contextInfo:)), nil)

             }

Aucun commentaire:

Enregistrer un commentaire