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 trialgökhan sayılgan
2,285 Pointsits not working at x code 7.2
i have check all questions and approaches before me non is solving my problem. i have write everything same in the video nothing has changed. first error is use a " ! " operator for "as" key (i have done that but still doesn't work) . second error is intance member segueLabelText cannot be used on type 'PlaylistDetailViewController'.
please reload this video for new version of x code or for now send us a solve of that problem just and save the day
thank you
gökhan sayılgan
2,285 Pointsimport 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.
}
}
9 Answers
Albert González
22,953 PointsIn this video, the code is for the old Xcode and not for the new Xcode 7. You have to download the project from the downloads and see the code asociated.
gökhan sayılgan
2,285 Pointsi compare that file with mine there is no difference (cuz i also tried bang operator) mine didn't work but that one have is working. Any way it should be my mistake or something must be missing thank you for solving my problem
Albert González
22,953 PointsZachary, make a clean of your project
Ana Marquez
742 PointsThis line is incorrect: PlaylistDetailViewController.segueLabelText = "Yay, you pressed the button"
Corrected: playlistDetailController.segueLabelText = "Yay, you pressed the button"
You're supposed to call the constant.
erikslagter
7,567 PointsEven with the project file downloads, I'm unable to get the app to build. The "as!" doesn't work. App only crashed on build.
gökhan sayılgan
2,285 Points1)download project zip file 2) open it with x code 3)close pdf explanation about difference between as and as! operators 4) open again your project 5)copy and paste masterViewController codes to your own project from download 6)copy and paste detailViewController codes to your own project from download
Note= probably you forget to replace master or detail view controller codes with downloaded file codes
zacharymariscal
2,714 PointsMy 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!"
}
}
I'm running into the same issue as people above. I get an error saying "Use of unresolved identifier 'playlistDetailViewController'.
Any ideas?
zacharymariscal
2,714 PointsRestarted Xcode a few times and this resolved on it's own. Odd, but happy to be able to move on.
Kyle Robertson
31,600 PointsInstead of typing out playlistDetailController.segueLabelText, I copied and pasted it from the constant declared above, and then the app built fine for me.
gökhan sayılgan
2,285 Pointsthank you guys i have done it as Albert said
David Urbonas
9,405 PointsThis is infuriating!
I've tried all of the above and still doesn't work!
keeps asking for a "!" after as. What's going on?
Albert González
22,953 PointsDid you change the "!" for the "?"
David Urbonas
9,405 PointsNot sure what you mean Albert
David Urbonas
9,405 PointsI've copy and pasted the code from the download files and still getting this error "UIViewController" is not convertible to "PlaylistDetailViewController"; did you mean to use "as!" to force downcast.
Adding the "!" to "as" I then get a console error of "Unknown class PlaylistDetailViewController in Interface Builder file."
thoughts?
gökhan sayılgan
2,285 Pointsgökhan sayılgan
2,285 Points