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 Music Library and Playlist Models Passing the Playlist Object

After pushing "Press Me" it doesn't says Rise and Shine, it still says You Haven't Pressed Button Yet?

I did get some errors in Swift following the instructions in the video, so I did use the Swift suggestions for fixing the code which did get rid of the errors. Also, I deleted "You Have Already Pressed the Button" and added did add where it starts at playlist index point zero. So not sure how to fix this.

This is Playlist Detail View Controller:

import UIKit

class PlaylistDetailViewController: UIViewController {

@IBOutlet weak var buttonPressLabel: UILabel!
var playlist = Playlist?()


 override func viewDidLoad() {
    super.viewDidLoad()

    if playlist != nil {
        buttonPressLabel.text = playlist!.title


    }

}

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

}

This is Playlist Master View Controller:

import UIKit

class PlaylistMasterViewController: UIViewController {

@IBOutlet weak var aButton: UIButton!

@IBOutlet weak var playlistImageView0: UIImageView!

override func viewDidLoad() {
super.viewDidLoad()

    aButton.setTitle("Press Me!", forState: .Normal)

    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 == "showPlaylistDetail" {
       let playlistDetailController = segue.destinationViewController as! PlaylistDetailViewController
        playlistDetailController.playlist = Playlist(index: 0)


}

}

}

1 Answer

I see where you set a value for the button's title:

aButton.setTitle("Press Me!", forState: .Normal)

I also see where you set playlist to the 0th Playlist, and the image to playlist.icon:

    let playlist = Playlist(index: 0)
    playlistImageView0.image = playlist.icon

I don't see where you set the button's title to playlist.title