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 trialYalamber subba
10,943 Points'AnyObject?' is not convertible to 'String'; did you mean to use 'as!' to force downcast? in xcode 6.3
In PlayList StructI start to get following error on line inside init function
title = playListDictionary["title"] as String! description = playListDictionary["description"] as String!
'AnyObject?' is not convertible to 'String'; did you mean to use 'as!' to force downcast? in xcode 6.3
This used to work ok before upgrading to xcode 6.3
2 Answers
kjvswift93
13,515 PointsThis is an example of one of the changes in the version 1.2 release of the swift language. The error is due to the new as! operator and downcasting. Swift 1.2 now wants you to be more explicit with optional vs. non-optional type conversions.
Steve Hunter
57,712 PointsIgnore my previous answer, I'm getting exactly the same as you ... I did a rebuild and the errors all sprung into life!
Using the auto-fix clears all the errors and the app works just fine.
Steve Hunter
57,712 PointsHaving said that, I do get that error in other areas of the same project. It wants me to replace as
with as!
. Must be a new release of Swift.
Yalamber subba
10,943 PointsCould be new version of swift. After replacing it works fine
Yalamber subba
10,943 PointsYalamber subba
10,943 PointsHello kyle, What is difference in as! and as? When using as! i get warning to have it changed to as?
Thank you