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!
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
yi yuan2,436 Points
Sample Code doesn't work
I have followed the tutorial and also update the code syntax based on the Teacher's Notes, but let baseURL = NSURL(fileURLWithPath: "https://api.forecast.io/forecast/\(apiKey)/") let forecastURL = NSURL(string: location, relativeToURL: baseURL) let weatherData = NSData(contentsOfURL: forecastURL, options: nil, error: nil) still doesn't work. Even the code I download from the sample is still not working. Any idea or update, please help! Thanks.
Oliver Pinchbeck2,732 Points
Maybe check your Xcode version? The NSData function changed between Xcode 6.0 and 6.1 I think
Ludwing Najera4,596 Points
The same thing's happening to me, and the console says "fatal error: unexpectedly found nil while unwrapping an Optional value". Does that mean anything to any of you?
Queenie Peng8,052 Points
- Check if there's any space in baseURL and forecastURL
- Use "!" to unwrap the optional value