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


james bunn
james bunn
2,377 Points

"Cannot assign to property: "playlist" is a let constant"

Getting the error in the prepareForSegue method. For some reason, the fix it option is to change "playListImage5" UIImageView to "playListImvar5"


import UIKit

class MasterViewController: UIViewController {

@IBOutlet weak var playListImage0: UIImageView!
@IBOutlet weak var playListImage1: UIImageView!
@IBOutlet weak var playListImage2: UIImageView!
@IBOutlet weak var playListImage3: UIImageView!
@IBOutlet weak var playListImage4: UIImageView!
@IBOutlet weak var playListImage5: UIImageView!

var playListArray: [UIImageView] = []

override func viewDidLoad() {

    playListArray += [playListImage0, playListImage1, playListImage2, playListImage3, playListImage4, playListImage5]

    for index in 0..<playListArray.count {
        let playlist = PlayList(index: index)
        let playListImage = playListArray[index]

        playListImage.image = playlist.icon
        playListImage.backgroundColor = playlist.backgroundColor


    // Do any additional setup after loading the view, typically from a nib.

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

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "showPlayListDetail" {

        let playListImage = sender!.view as! UIImageView
        if let index = playListArray.indexOf(playListImage)
            let detailListController = segue.destinationViewController as! DetailViewController
            detailListController.playlist = PlayList(index: index)



@IBAction func imageTap(sender: AnyObject) {
    performSegueWithIdentifier("showPlayListDetail", sender: sender)


1 Answer

james bunn
james bunn
2,377 Points

Never mind. On the DetailController I had the "playlist" variable set as a constant. After updating to be "Var", the error cleared