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 trialStephen Wall
Courses Plus Student 27,294 PointsI can't seem to reference that Star image in code.
My Xcode cant see the Star icon from the assets folder in code. Is there a way to fix this? If not is there a work around?
Ryan McArthur
3,683 PointsI had this same problem in the Interactive Story. It works if you enter
#imageLiteral(resourceName: "Star")
in place of the reference.
If you copy the references like that into another text editor, I guess that's the code underneath. As to why it's not finding the reference in the same way in the video, I'm really not sure, but if someone else knows, I'd be interested to know.
Unsubscribed User
Courses Plus Student 22,129 PointsIn Swift 5 and above, you can use either of the commented out lines
if contact.isFavorite {
//contactCell.favoriteIcon.image = UIImage(imageLiteralResourceName: "Star")
//contactCell.favoriteIcon.image = UIImage(named: "Star")
//contactCell.favoriteIcon.image = #imageLiteral("Star") //Should Autocompleted with the image
}
1 Answer
Robert Fenstermaker
Full Stack JavaScript Techdegree Student 26,519 PointsOne other note, you can punch in #imageLiteral or just start typing image literal and select it and a generic image icon will appear. Double click that icon and you can then select the image. Seems like a weird new system but that works at least.
Oleksadr Holovin
1,708 PointsOleksadr Holovin
1,708 PointsHey i have a same problem, do you fixed it?