Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 :).