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 trialConnor Hartland
1,365 PointsWhen I go into playground and try to press the white dot. All I get back is nil.
It is not coming up with a bunch of things on the right like in the video
5 Answers
Eddie Dale
1,554 PointsI had the same problem. My solution was to add a "bang" to the forecast constant. This is because of the syntax change from apple.
So my working code in the playground is:
let apiKey = "INSERT_YOUR_API_KEY"
let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/")
let forecastURL = NSURL(string: "37.8267,-122.423", relativeToURL: baseURL)
forecastURL!
Then clicking the white dot on the last line "forecastURL!"
Ben Goertz
3,411 PointsI had the same problem. My console was outputting:
2014-12-12 14:36:36.416 MyPlayground[6595:243712] NSURLConnection/CFURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9807) nil
After watching the video again, I cleaned up my code to match his exactly - the initial code I copied was slightly different. Comment out or delete the let weatherData
code block. That's where our console output is coming from - println(weatherData)
.
With that gone, I realized I actually was getting back the JSON but it's buried in another modal preview (the eyeball icon on the far right). I'm assuming my output preview is different than the video because of recent changes in Xcode and the tweaks Apple has been making to playgrounds and Swift. I'm using Xcode 6.1.1.
Hope that helps!
Jared Watkins
10,756 PointsI had to click on the white dot on the 'let forecastURL' line, then click on the eyeball in the small box below the big error message. There ways a pop-out with the JSON weather data.
Jeffrey Chan
2,249 Pointsimport UIKit
var str = "Hello, playground"
let apiKey = "xxx"
let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/")
let forecastURL = NSURL(string: "40.678840,-73.948774", relativeToURL: baseURL)
let weatherData = NSData(contentsOfURL: forecastURL!, options: nil, error: nil)
println(weatherData)
I'm getting nil after "let weatherData". I can't seem to figure this one out either.
EDIT: Comment out everything starting from "let weatherData". On the "let forecastURL" line, click the eyeball. Hover over the URL that pops up and click on THAT eyeball to see your weather data.
Jirayu Piriyametha
2,987 Pointssame problem after click white dot just like in the VDO I Can't get the result.
2015-01-01 22:30:07.586 MyPlayground[838:17934] Failed to obtain sandbox extension for path=/var/folders/my/t0mksl5s2x96vsrpzfvc6j8h0000gn/T/com.apple.dt.Xcode.pg/containers/com.apple.dt.playground.stub.iOS_Simulator.MyPlayground-0F910F4D-764D-420D-B6EE-1228B5D1389E/Library/Caches/com.apple.dt.playground.stub.iOS_Simulator.MyPlayground-0F910F4D-764D-420D-B6EE-1228B5D1389E. Errno:1 2015-01-01 22:30:07.587 MyPlayground[838:17934] Failed to obtain sandbox extension for path=/var/folders/my/t0mksl5s2x96vsrpzfvc6j8h0000gn/T/com.apple.dt.Xcode.pg/containers/com.apple.dt.playground.stub.iOS_Simulator.MyPlayground-0F910F4D-764D-420D-B6EE-1228B5D1389E/Library/Caches/com.apple.dt.playground.stub.iOS_Simulator.MyPlayground-0F910F4D-764D-420D-B6EE-1228B5D1389E. Errno:1 Optional(<7b226c61 74697475 6465223a 33372e38 3236372c 226c6f6e 67697475 6465223a 2d313232 2e343233 2c227469 6d657a6f 6e65223a 22416d65 72696361 2f4c6f73 5f416e67 656c6573 222c226f 66667365 74223a2d 382c2263 75727265 6e746c79 223a7b22 74696d65 223a3134 32303132 36323039 2c227375 6d6d6172 79223a22 436c6561 72222c22
Karl Metum
3,447 PointsDid you solve this?
Jeff Lyons
7,243 PointsJeff Lyons
7,243 PointsThis did it for me. All I saw was "Some https://......" in the console, but adding the "forecaseURL!" gave me what I needed to move on. Thanks!
Joshua Peterson
17,515 PointsJoshua Peterson
17,515 PointsWell done mate! I tried printing out forecastURL but it was not working. I guess I needed to unwrap it! Thanks!