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

I'm really confused on this coding challenge.

I don't have any additional code and was wondering if anyone could guide me through the process of how to complete this.

Thanks

1 Answer

GURJAP SINGH
GURJAP SINGH
7,556 Points

@Matthew Giuliano

in the challenge basically they have given you a dictionary called friends and this dictionary has a key named as profilePicture.

In the first part of the code they are asking you to retrieve the image name as a string and store it into a constant named profileImageName. Therefore:

//retrieving and storing the value
     let profileImageName = friends["profilePicture"] as String! 

now we have the stored value and it needs to be saved in a constant called profilePicture as the second part of the question.

let profilePicture = UIImage(named:profileImageName)

overall your code should look like below

  //Add your code below
        let profileImageName = friends["profilePicture"] as String!
        let profilePicture = UIImage(named:profileImageName)