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 trialRune Jacobsen
15,650 PointsI get the error "PlaylistDetailViewController .Type does not have a member named segueLabelText
I have been checking this so long, I can't seem to find the error? I tried editing segueLabelText to buttonPressLabel.text but that didn't work for me either.. Here is my 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
PlaylistDetailViewController.segueLabelText = "Yay! You pressed the button!"
}
}
}
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
Brayden Kness
12,492 PointsIt's a very simple and annoying error but this is your code:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showPlaylistDetail" {
let playlistDetailController = segue.destinationViewController as! PlaylistDetailViewController
PlaylistDetailViewController.segueLabelText = "Yay! You pressed the button!"
}
}
In the line where you try and set segueLabelText you are using PlaylistDetailViewController the class name and not playlistDetailViewController the instance of PlaylistDetailViewController
I hope this isn't confusing but this is what is should be:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "showPlaylistDetail" {
let playlistDetailController = segue.destinationViewController as! PlaylistDetailViewController
playlistDetailViewController.segueLabelText = "Yay! You pressed the button!"
}
}
Rune Jacobsen
15,650 PointsRune Jacobsen
15,650 PointsThank you so much! Luckily I found the error myself the day after, probably just needed to take me eyes from it a bit.
Anyways thanks a lot!