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 Refactoring Our Code Determining Playlists Programmatically

The downloadable files have lots of errors!

I am picking up this course where I left off on my iMac so I'm downloading the files but they have many errors

Chris Shaw
Chris Shaw
26,676 Points

Hi Rolando,

Which version of Xcode do you have? The reason I ask is because Swift 1.2 aka Xcode 6.2 changed a lot which resulted in some code suddenly breaking.

If you list some of the errors we can assist you further but while I'm at work it's hard to find them as I don't have my MacBook with me.

Yeah I updated to Swift 1.2 and there's about 7 errors going on. Chris Upjohn

1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Rolando,

I've taken a look at the files and have fixed the errors causing the problems, as an overview Swift 1.2 changed everything to be an optional which means we now need to unwrap values using the question mark which safely unwraps an object along with the bang ! which will trigger an error if the object is nil as it implies a forceful downcast.

In this project you will notice in Playlist.swift I've used the bang as! instead of a question mark for the below line, the reason for this is the += operator doesn't allow for nil values which means if our artists array is empty our code will fail, in our case we don't ever expect this to happen but for your own projects it's better to check if anything exists in the object before attempting to grab it's data.

artists += playlistDictionary["artists"] as! [String]

Download updated files for Swift 1.2

For more information about the changes to Swift see the below link.

http://www.raywenderlich.com/95181/whats-new-in-swift-1-2

Hope that helps.

Thank you so much Chris Upjohn !