IPhone : Code missing in Swift for Playlist Browser (Treehouse Project)

on Wednesday, April 8, 2015

I'm building my second-ever iPhone app with Treehouse Tutorials, and I've checked and double-checked with the tutorial's code. I can't find any differences, but mine isn't working. It feels as if something's missing...


From the PlaylistDetailViewController, which is the second view:



import UIKit


class PlaylistDetailViewController: UIViewController {



var playlist: Playlist?
//sets property to nil until we're ready to assign it
@IBOutlet weak var playlistCoverImage: UIImageView!
@IBOutlet weak var playlistTitle: UILabel!
@IBOutlet weak var playlistDescription: UILabel!

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

override func viewDidLoad() {
super.viewDidLoad()

if playlist != nil {
playlistCoverImage.image = playlist!.icon
playlistCoverImage.backgroundColor = playlist!.backgroundColor
playlistTitle.text = playlist!.title
playlistDescription.text = playlist!.description

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

}
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()


I feel there's something missing similar to this in the MasterViewController that calls the images and background colors:



playlistArray += [playlistImageView0, playlistImageView1, playlistImageView2, playlistImageView3, playlistImageView4, playlistImageView5]

for index in 0..<playlistArray.count {
let playlist = Playlist(index: index) //instance
let playlistImageView = playlistArray[index]

playlistImageView.image = playlist.icon
playlistImageView.backgroundColor = playlist.backgroundColor
} //gets all cover images and playlists


playlistArray.append(playlistImageView0)


The playlistArray is never called in the DetailView, right? That's where the largeIcon, title, description, etc are...


Any ideas?


0 comments:

Post a Comment