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 Master and Detail Views Displaying Playlist Information

Ali Bouland
Ali Bouland
3,479 Points

Nothing is updating..

when I run my app the labels and the ImageView do not get updated, I'm sure it has to do with the IBOutlets but I cannot find out what's wrong

here is my detailViewController code:

import UIKit

class PlaylistDetailViewController: UIViewController {

    var playlist: Playlist?

    @IBOutlet weak var playListCoverImage: UIImageView!
    @IBOutlet weak var playListDescription: UILabel!
    @IBOutlet weak var playListTitle: UILabel!
    var segueLabelText: String = ""

    override func viewDidLoad() {
        super.viewDidLoad()
        if playlist != nil {
            playListCoverImage.image = playlist!.largeIcon
            playListCoverImage.backgroundColor = playlist!.backgroundColor
            playListTitle.text = playlist!.title
            playListDescription.text = playlist!.description
        }

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

and here's my MasterViewController code also:

import UIKit

class PlaylistMasterViewController: UIViewController {

    @IBOutlet weak var aButton: UIButton!
    @IBOutlet weak var playlistImageView0: UIImageView!
    @IBOutlet var backgroundColor: UIView!

    override func viewDidLoad() {
        super.viewDidLoad()

        aButton.setTitle("Press me!", forState: UIControlState.Normal)
        let playlist = Playlist(index: 0)
        playlistImageView0.image = playlist.icon
        backgroundColor.backgroundColor = playlist.backgroundColor
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }







    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        if segue.identifier == "showPlaylistDetail" {
            let playlistDetailController = segue.destinationViewController as! PlaylistDetailViewController
            playlistDetailController.segueLabelText = "Yay! You pressed the button"
        }
    }
}

1 Answer

Ali Bouland
Ali Bouland
3,479 Points

I found the mistake, my last line of code in the MasterViewController was missing:

playlistDetailController.playlist = Playlist(index: 0)