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!

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 Creating UIImageView instances

Richard Price
Richard Price
2,050 Points

Where to Start? Build a playlist

its time for another annoying challenge where you get to the end and feel you haven't learnt anything at all. Really tedious

anyway has anyone managed to do this challenge as I don't even know where to start

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {

        let friends = Treehouse().friends

        //Add your code below


struct Treehouse {
    let friends = [
        "firstName": "Susan",
        "lastName": "Olson",
        "profilePicture": "susan_profile.png"

1 Answer

Hi Richard,

The below solution should work:

        let friends = Treehouse().friends
        let profileImageName = friends["profilePicture"]!
        let profilePicture = UIImage(named: profileImageName)

Just to expand - we've already created an instance of the Treehouse struct dictionary friends and called it friends. We then access the key profile picture and store the string in the constant profileImageName.

We can then pass profileImageName into the UIImage constant profilePicture to store our chosen image.

Hi Caleb,

The solution above works ok for me.

Did you remember to unwrap using the '!' symbol?

should all go in the ImageView file. No need to amend the Treehouse.swift file

Caleb Kleveter
Caleb Kleveter
Treehouse Moderator 37,862 Points

Okay, I figured out my issue. I didn't realize that the challenge was for Swift, not Objective-C :).