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 trialJay Woo
1,915 PointsUndeclared type "PlaylistDetailViewController"
Hi, I got a problem, I follow Pasan Premaratne step by step doing... but still something wrong with my code, could you please help me, Thanks~ here is code.
import UIKit
class PlaylistMasterViewController: UIViewController {
@IBOutlet weak var aButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
aButton.setTitle("Press me!", forState: .Normal)
}
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 // error said: Undeclared type "PlaylistDetailViewController"
playlistDetailController.buttonPressLabel.text = "Yay! You Pressed the button"
}
}
}
import UIKit
class PlaylistDetailViewController: UIViewController {
@IBOutlet weak var buttonPressLabel: UILabel!
var segueLabelText: String = ""
override func viewDidLoad() {
super.viewDidLoad()
buttonPressLabel.text = segueLabelText
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
1 Answer
Brendan Corey
Courses Plus Student 5,745 PointsYour code looks pretty good. Maybe try replacing: playlistDetailController.buttonPressLabel.text = "Yay! You Pressed the button" with: playlistDetailController.segueLabelText = "Yay! You pressed the button"
Scott Baumbich
Courses Plus Student 22,129 PointsScott Baumbich
Courses Plus Student 22,129 PointsA few things I would check based on what you have provided here 1) make sure you have named you segue identifier "showPlaylistDetail" without the quotes 2) Be sure you have set the class of the detail view on the Main story identity inspector to PlaylistDetailViewController
please confirm that you have done those two steps