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 Struct Initialization

maq
maq
1,297 Points

Use of unresolved identifier 'musicLibrary'

I keep getting "Use of unresolved identifier 'musicLibrary'" in the init function. I've followed the teacher as best as I could and am not sure what I'm doing wrong. Here's my code for that function, I would appreciate any help:

  init(index: Int) {
        let musiclibrary = MusicLibrary().library
        let playlistDictionary = musicLibrary[index]

        title = playlistDictionary["title"] as String!
        description = playlistDictionary["description"] as String!

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


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

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

        let colorsDictionary = playlistDictionary["backgroundColor"] as [String: CGFloat]

        backgroundColor = rgbColorFromDictionary(colorsDictionary)


    }
Jhoan Arango
Jhoan Arango
14,575 Points

Hello:

I edited your question so that your code is readable!

1 Answer

It is probably that you just mispelled the variable name. You first instantiated the variable as musiclibrary (l) and then assigned the variable musicLibrary (L). Swift if case sensitive.

maq
maq
1,297 Points

Thank you! I did not even catch that.