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 Using a Playlist Instance

Jeremy Yi
Jeremy Yi
9,512 Points

Thread 1: breakpoint 1.1

I did all the code right I believe. But at this line:

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

there would be a breakpoint and I don't know why, if anyone comes into same problem here?

struct Playlist {

    var title: String?
    var description: String?
    var icon: UIImage?
    var largeIcon: UIImage?
    var artists: [String] = []
    var backgroundColor: UIColor = UIColor.clearColor()

    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 = rgbFromDictionary(colorsDictionary)
    }

    func rgbFromDictionary(colorDictionary: [String: CGFloat]) -> UIColor {

        let red = colorDictionary["red"]!
        let green = colorDictionary["green"]!
        let blue = colorDictionary["blue"]!
        let alpha = colorDictionary["alpha"]!

        return UIColor(red: red/255.0, green: green/255.0, blue: blue/255.0, alpha: alpha)
    }
}

1 Answer

Reed Carson
Reed Carson
8,306 Points

I haven't taken this lesson but if i understand your question correctly your code is halting because its coming to a breakpoint. A breakpoint is a terribly annoying feature in Xcode that you can click on by accident which causes the compiler to halt when it reaches that particular line of code. On the gutter to the left of your code, you can click on the number of the line and create a breakpoint which is for debugging purposes. Look for any rectangles with a pointed end in the gutter to the left of the line in question. you can click and drag them off the gutter then let go to get rid of them. they will "poof" and disappear

Jeremy Yi
Jeremy Yi
9,512 Points

whoa, that is pretty easy one. Thx Reed.