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

Attaching a JPG to UIImage in Xcode

I'm trying to figure out how to attach a jpg image to UIImage in Xcode. Im trying to build a coin flip app to practice and want to attach coin face images to a struct containing the base properties for Coin. Here's my struct so far:

struct Coin { let coinFront = UIImage(named: "1804 Silver Dollar Front.jpg") let coinBack = UIImage(named: "1804 Silver Dollar Back.jpg") }

1 Answer

You should modify your image name for example 1804_silver_dollar_back.jpg

And you can use it directly to the outlet. Try myImageView = UIImage(named:"1804_silver_dollar_back")

Good luck

Ah, that works perfect. Thanks!