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


Christine Rose
Christine Rose
6,745 Points

Missed something in the PlaylistDetailViewController...can't figure out what.

I'm coming to the end of these pretty app, and I'm quite proud of myself for de-bugging my own script and using internet resources to help me do that to fix errors.

However...the app now builds just fine, and it even goes to the next screen when tapped, but the subsequent screen (PlaylistDetailViewController) doesn't populate with the information from the array. No picture or text other than the placeholders.

import UIKit

class PlaylistDetailViewController: UIViewController {

    var playlist: Playlist?
    //sets property to nil until we're ready to assign it
    @IBOutlet weak var playlistCoverImage: UIImageView!
    @IBOutlet weak var playlistTitle: UILabel!
    @IBOutlet weak var playlistDescription: UILabel!

    @IBOutlet weak var playlistArtist0: UILabel!
    @IBOutlet weak var playlistArtist1: UILabel!
    @IBOutlet weak var playlistArtist2: UILabel!

    override func viewDidLoad() {

        if playlist != nil {
            playlistCoverImage.image = playlist!.icon
            playlistCoverImage.backgroundColor = playlist!.backgroundColor
            playlistTitle.text = playlist!.title
            playlistDescription.text = playlist!.description

            playlistArtist0.text = playlist!.artists[0]
            playlistArtist1.text = playlist!.artists[1]
            playlistArtist2.text = playlist!.artists[2]


    override func didReceiveMemoryWarning() {


I'm guessing I missed some code along the way...

It seems to me there should be some code like this:

playlistArray += [playlistImageView0, playlistImageView1, playlistImageView2, playlistImageView3, playlistImageView4, playlistImageView5]

        for index in 0..<playlistArray.count { //gets range of numbers representing the number in playlistArray
            let playlist = Playlist(index: index) //instance
            let playlistImageView = playlistArray[index]

            playlistImageView.image = playlist.icon
            playlistImageView.backgroundColor = playlist.backgroundColor

That's from the MasterViewController page, and it enables the different picture and color backgrounds for the Master View. That works, and it's lovely.

I don't see anything actually calling and paging through the playlistArray to get the titles, etc. Did the videos miss a step? I reviewed the section where he went over this, and I checked and double-checked my code against his, but mine doesn't work.

His does.