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 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