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 trialTyler Banks
3,109 PointsBuild a Playlist Browser with Swift, refactoring our code, Adding Multiple Playlists
Hi there! I'm getting and error which says: unexpectedly found nil while unwrapping an optional value, here is my code https://github.com/Tyler135/Algorhythm.git Thanks in advance
1 Answer
Steve Hunter
57,712 PointsFound the problem - your MusicLibrary is incomplete. I've amended the code and uploaded to Github and sent a pull request. I've added:
"largeIcon": "ball_large.pdf",
"backgroundColor": ["red": 255, "green": 102, "blue": 153, "alpha": 1.0],
"artists": ["Shakira", "Santana", "Wyclef Jean", "Aloe Blacc", "Pitbull", "Enrique Iglesias", "Ricky Martin"]
to your Playlist.swift
file. You were getting a nil
as you unwrapped largeIcon
because it isn't in your code. A quick check through the debugger showed that the issue was with largeIcon
so I checked the basics first, like does it exist! It didn't - problem solved!
Log back into Github and merge the changes, then pull that down to your machine - should work fine.
Steve.
Tyler Banks
3,109 PointsTyler Banks
3,109 PointsThanks a lot, it worked!
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsNo problem - hope it worked!
Steve.