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 trialJoey Liu
3,982 Pointsmy 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
14,575 PointsHello,
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
10,156 PointsAdolfo Obregon
10,156 PointsHi, 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
14,575 PointsJhoan Arango
14,575 PointsAdolfo,
I am sorry for the late response, are you able to show me your code?