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

iOS Build a Playlist Browser with Swift Building the Music Library and Playlist Models Struct Initialization

Ian Donovan
Ian Donovan
3,166 Points

Xcode 6.4, as! v. as?, String! v. String!

I'm having a bit of trouble following the end of this video with the newest version of Xcode.

Specifically, I'm getting an error on the last line, artists += playlistDictionary["artists"] as! [String]

That's what I've got, at least, anyway, after fussing with all the combinations of !, ?, etc. Can someone tell me what this line is supposed to be? The error I'm getting is "Binary operator '+=' cannot be applied to two [String] operands." I'm a rubyist, and += works on arrays just fine there, so I'm at a bit of a loss.

EDIT: Changing artists from a constant to a variable in the struct declaration . . . fixed it. Oooookay.

Karl Metum
Karl Metum
3,447 Points

+1 for being a rubyist ;)