Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Weather App Modeling Forecast Data Icon Images

Joey Liu
Joey Liu
3,982 Points

my clear-day doesn't turn into image

var iconImage: UIImage {
        switch icon {
        case "clear-day": return clear-day
}

so my clear-day doesn't pop up in the list for me to select like the video revealed that I cannot turn it into images in Asset.xcasset. What is the possible problem? Do I have to use #imageLiteral(resourceName: ) ?

1 Answer

Jhoan Arango
Jhoan Arango
14,575 Points

Hello,

So this computed property should return a "UIImage", and you are just returning "clear-day" string. To fix this, you have to use the UIImage initializer "named". This will make an image, and then you will return it.

var iconImage: UIImage {
        switch icon {
        case "clear-day": return UIImage(named: "clear-day")
        default: break
        }
}

Hope this help

Adolfo Obregon
Adolfo Obregon
10,156 Points

Hi, i had the same issue but now im gettin the following error : Value of optional type 'UIImage?' must be unwrapped to a value of type 'UIImage'

Jhoan Arango
Jhoan Arango
14,575 Points

Adolfo,

I am sorry for the late response, are you able to show me your code?