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.

iOS Build a Playlist Browser with Swift Building the Master and Detail Views Adding Touch Capabilities

Kevin Gonzales
Kevin Gonzales
4,638 Points

So I keep getting an error can someone help?

Heres is my code please help I am not sure whats wrong. Also please also explain so I can learn how to fix these errors. Thank you !

// // ViewController.swift // Algorhythm // // Created by Kevin Gonzales on 6/2/15. // Copyright (c) 2015 HowWeLife. All rights reserved. //

import UIKit

class PlaylistMasterViewController: UIViewController {

@IBOutlet weak var playlistImageView0: UIImageView!
@IBOutlet weak var Button: UIButton!


override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.


    //crashes and highlights in green here 
    let playlist = Playlist(index: 0)
    playlistImageView0.image = playlist.icon

}

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

}



override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    if segue.identifier == "showPlayListDetailSegue" {
        let playlistDetailControler = segue.destinationViewController as! PlaylistDetailViewController

        playlistDetailControler.playlist = Playlist(index: 0)
    }
}

@IBAction func showPlaylistDetail(sender: AnyObject) {
        performSegueWithIdentifier("showPlayListDetailSegue", sender: sender)
}

}

then this

// // PlaylistDetailViewController.swift // Algorhythm // // Created by Kevin Gonzales on 6/2/15. // Copyright (c) 2015 HowWeLife. All rights reserved. //

import UIKit

class PlaylistDetailViewController: UIViewController {

@IBOutlet weak var playlistCoverImage: UIImageView!
@IBOutlet weak var playlistTitle: UILabel!
@IBOutlet weak var playlistDescirption: UILabel!

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

var playlist: Playlist?


override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.

    if playlist != nil {

        playlistCoverImage.image = playlist!.largeIcon
        playlistCoverImage.backgroundColor = playlist!.backgroundColor
        playlistTitle.text = playlist!.title
        playlistDescirption.text = playlist!.description

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

    }


}

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

}

I will post anything else if asked. I am not sure if the error is with code or with the views .

1 Answer

Radu Savutiu
Radu Savutiu
3,167 Points

You should post the error message you receive?