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 trialMichael Zaro
13,196 PointsHints to get description to display?
I am unable to get the playlist description to display. I will post my code, but I cannot find the problem. Everything is compiling. I downloaded the project from the downloads for this video and compared everything that I can find and everything seems to be the same, except that I the description is not displaying. Any ideas what might be wrong?
// PlaylistDetailViewController.swift
// Algorythm
//
// Created by James Plauche on 8/17/15.
// Copyright (c) 2015 Tanner PlauchΓ©. All rights reserved.
//
import UIKit
class PlaylistDetailViewController: UIViewController {
var playlist = Playlist?()
@IBOutlet weak var playlistCoverImage: UIImageView!
@IBOutlet weak var playlistTitle: UILabel!
@IBOutlet weak var playlistDescription: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
if playlist != nil {
playlistCoverImage.image = playlist!.largeIcon
playlistCoverImage.backgroundColor = playlist!.backgroundColor
playlistTitle.text = playlist!.title
playlistDescription.text = playlist!.description
}
func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
}
2 Answers
Michael Zaro
13,196 PointsOk. Ok. Ok. This happens every time. I try to solve a problem myself, and then I don't figure it out until AFTER I think I have exhausted myself looking for the solution.
The problem was in my struct initializer. I used the key "dictionary" instead of "description". I'm not sure what I was thinking when I wrote that.
Nicholas Westmoreland
5,937 PointsI'm battling to get description to display too. Unfortunately no typo that I can find yet. Description displays fine in the playlistTitle label, but not in the playlistDescription label. playlistDescription.text = "trying to debug" displays fine too. ....???????
edit: solution found in typo in Playlist.swift file description = playListDictionary["typo was here"] as! String!
Daniel Whitaker
10,996 PointsDaniel Whitaker
10,996 PointsI actually did the exact same thing... very strange