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 Telford
2,931 Pointswhy don't i see the option for dataWithContentsOfURL ?
I'm following along with the tutorial and I'm having a problem, when Pasan is creating the weatherData constant when he's typing the code he gets multiple options after typing 'NSData.data' i only get one and its not the one i need. Is there any additional options i need to enable?
1 Answer
Chris Shaw
26,676 PointsHi Luke,
I would advise you to have a read through the teacher notes as Xcode 6.1 introduced some breaking changes which are covered in the notes.
Luke Telford
2,931 PointsLuke Telford
2,931 Pointsah thank you! i have done the changes that are provided but it still doesn't work, its saying 'fatal error: unexpectedly found nil while unwrapping an Optional value' in my console.
Chris Shaw
26,676 PointsChris Shaw
26,676 Pointsluke telford, could you please post the code you currently have, thanks.
Luke Telford
2,931 PointsLuke Telford
2,931 Pointsyea sure,
Chris Shaw
26,676 PointsChris Shaw
26,676 PointsHi luke telford,
The reason you're getting a
nil
error is because you have a space in your coordinates which has caught quite a number of users of guard asNSURL
objects don't like spaces unless they're encoded which we don't need to do here so we can simply remove it.let forecastURL = NSURL(string: "53.819912,-1.477529", relativeToURL: baseURL)
Luke Telford
2,931 PointsLuke Telford
2,931 PointsAh something so simple! it now runs but its returning nil in my command line where as Pasan's return a long Hex value, is this normal with the changes that have happened in Xcode or should i be also get a Hex value?
Chris Shaw
26,676 PointsChris Shaw
26,676 PointsI just tried your code and it worked fine, sometimes the simulator can have issues with HTTP requests, I would suggest you reset it via the Reset Content and Settings menu item under iOS Simulator as seen below.
Luke Telford
2,931 PointsLuke Telford
2,931 Pointsah i see, i have done that and although I'm still getting nil as an output in my console the app itself runs with no error popping up
Luke Telford
2,931 PointsLuke Telford
2,931 PointsI just downloaded the files from the course and its giving me the same error on mine so I'm guessing something has changed in Xcode? its saying "Value of optional type 'NSURL?' not unwrapped, did you mean to use '!' or '?'?
this is the line of code giving me this error
let downloadTask: NSURLSessionDownloadTask = sharedSession.downloadTaskWithURL(forecastURL, completionHandler: { (location: NSURL!, response: NSURLResponse!, error: NSError!) -> Void in