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

Can't seem to get this challenge right, could anyone help?

Heres the link for the challenge:


Thank you

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

Richard Lu
Richard Lu
20,185 Points

You want to create an UIImage with the profile picture key inside the dictionary. Since they've already provided the dictionary in the variable 'friends', I'd use that to obtain the image name.

let profilePicture = UIImage(named: friends["profilePicture"])

I hope I've helped! :)

Just a side thought

They should of made the friend's constant a static. The way it's currently currently set up, it could potentially waste more resources than it needs.