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 trialmaq
1,297 PointsUse 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)
}
1 Answer
Fabio Mingorance
3,520 PointsIt 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
1,297 PointsThank you! I did not even catch that.
Jhoan Arango
14,575 PointsJhoan Arango
14,575 PointsHello:
I edited your question so that your code is readable!