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 trial
Jeff Andersen
1,947 PointsDifference between as, as! and as? when unwrapping an optional
I'm working through the Build a Playlist Browser with Swift project and have run into an issue.
Unlike what Pasan has implemented in his code, XCode is suggesting that I use as! in place of as when assigning the playlistDictionary values.
For example, Pasan implements:
title = playlistDictionary["title"] as String!
but my XCode is suggesting I use:
title = playlistDictionary["title"] as! String!
On top of this, when I make the corrections as suggested by XCode, I receive "Unknown class Playlist in Interface Builder file." in my console output.
1 Answer
Jeff Andersen
1,947 PointsRe: "Unknown class Playlist in Interface Builder file.", I opened the code version of the storyboard file and noticed that somehow there was customClass="Playlist" on one of the nodes. Removing it removed the error.
Though, I'm not sure how it got there which I would like to understand.
Kevin Gonzales
4,638 PointsKevin Gonzales
4,638 Pointsso the video is a bit outdated and from the newer versions (what you have now, as well as everyone ) as = as! not sure about as?