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 trialKenton Raiford
5,101 Pointsas! Down casting not working. Please help.
Trying to get past this video but I've been stuck for a week now. I can't continue the project without fixing this error. Xcode keeps telling me to put as! but it's not fixing the error. Has anyone figured it out ? :D
6 Answers
Beatriz Macedo
9,903 PointsI was getting the "Consecutive Declarations On A Line Must Be Separated By ';'" (don't know if this was your error...) and I managed to fix it by retyping the line and adding as! as shown on the documentation (https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TypeCasting.html) for forced downcasting.
Unsubscribed User
6,281 PointsCan anyone please help, I have the same problem...
Deepa Laxmi
3,035 PointsI am also facing the same problem. Please let me know if u fix it.
Unsubscribed User
6,281 PointsWill do Deepa Laxmi. And you to, please let me know if you find an answer :)
Mohammed Mohammed
2,278 PointsYes, the down casting is not working, it shows an suggest to unwrap the optional. So any help would be appreciated.
Yupin Hu
3,702 Pointsfor the "as!" thing i think it's an new swift thing, so yes you do need to use it in order to make it work.
Here is how i fixed it and my code First, use "as!" Then, go to the storyboard and click on the "PlaylistDetailViewController", click on "identity inspector", finally click the dropdown of "module" and select "Algorhythm".
Good luck!
james bunn
2,377 PointsAny clue why the module must be selected as "Algorithm"?
Guillaume batier
1,387 Pointsi found it and it's work for me
if segue.identifier == "showPlaylistDetail" { if let playlistView = segue.destinationViewController as? PlaylistDetailController{ playlistView.segueLabelText = "test loaded"
}
}
Teja Kanchinadam
2,429 PointsThis worked for me! Thank you! If anyone else is facing the same problem, please follow the code above and don't forget to remove the code "aButton.setTitle("Press me!", ForState: .Normal)" from the viewDid load method of the first view controller.
Brendan O'Brien
5,521 PointsBrendan O'Brien
5,521 PointsI'm having a similar problem even after applying the Module fix suggested below. In my case, altering the down casting code from as to as! does fix the error, but for whatever reason, the string change specified that is passed via the segue doesn't occur. The default button text in the storyboard is overwritten by the PlaylistDetailViewController and therefore the button comes up blank. It would seem the "Yay etc." text is either not being passed. or is overwritten.
Here's my code:
PlaylistMasterViewController
PlaylistDetailViewController