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 Adding Multiple Playlists

Tyler Banks
Tyler Banks
3,109 Points

Build 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

Found 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
Tyler Banks
3,109 Points

Thanks a lot, it worked!

No problem - hope it worked!

Steve.