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.

Richard Price
2,050 PointsWhere 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() {
super.viewDidLoad()
let friends = Treehouse().friends
//Add your code below
}
}
struct Treehouse {
let friends = [
"firstName": "Susan",
"lastName": "Olson",
"profilePicture": "susan_profile.png"
]
}
1 Answer

tom barbour
3,865 PointsHi 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.
Caleb Kleveter
Treehouse Moderator 37,862 PointsCaleb Kleveter
Treehouse Moderator 37,862 PointsI tried this and it didn't work.
tom barbour
3,865 Pointstom barbour
3,865 PointsHi Caleb,
The solution above works ok for me.
Did you remember to unwrap using the '!' symbol?
Caleb Kleveter
Treehouse Moderator 37,862 PointsCaleb Kleveter
Treehouse Moderator 37,862 PointsWhich file do I put it in?
tom barbour
3,865 Pointstom barbour
3,865 Pointsshould all go in the ImageView file. No need to amend the Treehouse.swift file
Caleb Kleveter
Treehouse Moderator 37,862 PointsCaleb Kleveter
Treehouse Moderator 37,862 PointsOkay, I figured out my issue. I didn't realize that the challenge was for Swift, not Objective-C :).