Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


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