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 trialDavid Batista da Silva
1,479 PointsAccess to API returning NIL
I'm having problems accessing the API. In this xcode returning NIL, but if I use the URL in the browser works normally. Can be setup?
Note: The counter in the forecast site computing access.
My code in playground:
let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/")
let forecastURL = NSURL(string: "37.8267,-122.423?units=si&lang=pt", relativeToURL: baseURL)
let weatherData = NSData(contentsOfURL: forecastURL!, options: nil, error: nil)
1 Answer
Gareth Borcherds
9,372 PointsAre you sure your API key is correct?
I copied your code exactly as you had it with an API key I created and it worked just fine. That's the only difference I saw.
David Batista da Silva
1,479 PointsUsing NSURLSessionDownloadTask
work in implementing the app, but still does not work on the playground.
Can be setup? And the playground is no access?
Stone Preston
42,016 PointsStone Preston
42,016 Pointscan you post your code