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 trialJeff Aldrich
1,429 PointsGetting an error here with the new code: "fatal error: unexpectedly found nil while unwrapping an Optional value"
This is my code that's causing the error:
let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/")
// Do any additional setup after loading the view, typically from a nib.
let forecastURL = NSURL(string: "40.712908, -73.949399", relativeToURL: baseURL)
let weatherData = NSData(contentsOfURL: forecastURL!, options: nil, error: nil)
2 Answers
Jeff Aldrich
1,429 PointsAh, nm, found the error, I had a space between my coordinates when I copied and pasted from Google Maps. Removed the space, and now it works fine.
Ami Bhimani
6,373 Pointslet forcastURL = NSURL(string: "00.000000, __ -00.000000", relativeToURL: baseURL)
REMOVE SPACE __ and replace to
let forcastURL = NSURL(string: "00.000000,-00.000000", relativeToURL: baseURL)