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

Problem with code in Algorhythm in Building an iOS App, even though it's exactly as the instructor typed it.

I'm following along in Build a Playlist Browser and learning more about Swift, but I'm very confused right now. My code won't build because of two errors that make no sense to me:

THIS ONE WORKS:

let iconName = playlistDictionary["icon"] as String!
icon = UIImage(named: iconName)

But this one, same syntax, shows an error: (use of unresolved identifier 'largeIcon')

let largeIconName = playlistDictionary["largeIcon"] as String!
largeIcon = UIImage(named: largeIconName)

artists += playlistDictionary["artists"] as [String]

The error for the following says: expected member name or constructor call after type name

let colorsDictionary = playlistDictionary["backgroundColor"] as [String: CGFloat]
backgroundColor = rgbColorFromDictionary(colorDictionary: [String : CGFloat])
        //these two errors don't make sense, as they are exactly like the video...

Any ideas?

3 Answers

You are having this problem in the second case : because you didn't declare the if largeIcon is a constant or variable and the same thing for artists

That's exactly it! I just discovered it (2 minutes ago). largeIcon was left out of the group of variables. Yay! I figured it out. The var artists is declared.

But I still haven't figured out the next one: rgbColorFromDictionary...

Nevermind. Got it. Left the "s" off colorsDictionary. I'm getting this down! :)

nice lol :)