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 trialLuke Annison
7,724 PointsGetting error: "fatal error: unexpectedly found nil while unwrapping an Optional value"
Unfortunately on runtime the error above keeps appearing on various part of the application.
I managed to get rid of it once before but it is now showing up on the line:
artists += playlistDictionary["artists"] as! [String]
I'm wondering if anyone can shed some further light on what may be going on.
Thanks :)
Robin Malhotra
14,883 PointsI means that the value of swift playlistDictionary["artists"]
was nil on unwrapping. You may not have properly initialised the dict.
Jens Hagfeldt
16,548 PointsIt worked fine for me when only replacing all instances of (as) with (as!) in MusicLibrary.swift... because it was there you got the warnings before the error, was it not?
1 Answer
Luke Annison
7,724 PointsThanks for the answers everyone.
I'll have a look and report back when I get chance :)
Parker Skiba
5,583 PointsParker Skiba
5,583 PointsHow do you have your artists array defined?