UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Day 54 | Project 13 Challenge 1

Forums > 100 Days of Swift

Hi there,

I have completed challenges 2 & 3, but do not understand what I need to add/edit to the code to get an error to show when the save button is without an image...

I also don't know how to add images... of the code that i've tried. But, I've tried converting the guard let image = imageView.image into a if let and calling the image func withing that with an error, but it doesn't work.

Can anyone help me :')

PS. I've got no clue how to add images to this

3      

What you want to do is keep the guard let image = imageView.image but change the else clause to display an error before it returns.

You can take a look at the image(_:didFinishSavingWithError:contextInfo:) function for an example you already have of how to show an error message to the user.

As for posting images here, you have to have them hosted somewhere, such as Dropbox or Imgur or whatever, and then put the URL in some markdown like this:

![description of the image](url of the image)

(Note that with Dropbox, you have to change the end of the URL from dl=0 to raw=1 in order for the image to display inlie rather than be a link to click. I'm not sure if there are any changes needed for Imgur URLs.)

4      

Thank you for the advice @roosterboy!

Again I thought about doing that, and calling the image function inside the else of the guard let, I presumed that what the challenge was asking us to do is to invoke the first alertController in the image func as it's saying if let error = error { ....

How/What do I need to call the image function in the guard let ... else { to use that first AC. Or should I just be creating a 3rd alertController?

3      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.