"Displaying Data with Table Views in Swift 2" was retired on May 31, 2020. You are now viewing the recommended replacement.

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 Playlist Browser with Swift Building the Music Library and Playlist Models Using a Playlist Instance

No image displayed

Hi, My program is running, but no image is displayed in the Image View. The container is just orange, with nothing in it. I have added a property "iconFile" if Playlist struct, that contains the name of the file ("coffee.pdf" in our case) ... var iconFile : String ... let iconName = playListDictionary["icon"] as String! self.iconFile = iconName ... and i use a println in the viewDidLoad method to see if the dictionary is ok, which seems to be the case. ... let playList = PlayList(index: 0) playlistImageView0.image = playList.icon println(playList.iconFile) ... "coffee.pdf" appears in the debugger, at the bottom left. But the image "coffee.pdf" does not appear in the View.

Can you tell me why ? Thanks ! I really would like to fix this before going further.

3 Answers

Ok I have looked in the Internet and found the solution here : http://stackoverflow.com/questions/24049537/defining-the-file-a-uiimage-will-use-swift

the right parameter to create an Image with a file name is : UIImage(named: String) rather than UIImage(contentsOfFile: String)

and now it works !

thanks for your concern Greg, see U

Ah cool - thanks for updating us! For future reference, it's very helpful to actually see your code. Check out "Tips for asking questions" in the right sidebar ->

Hi Jeanne,

I think you might want coffee.png, rather than coffee.pdf.

Let me know if that works!

-Greg

Hi Greg, I'll try at home this evening, but I've pasted the exact same code as Pasan (in the "Teacher's notes" section), and it's "coffee.pdf". ++