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 trialMisho Milicevic
5,597 PointsStormy... Not retrieving weather data at final stage of completing app
I've followed the entire course, everything was working great, made the network calls, they worked. Now at the final stage with creating the UI the labels don't change and the forecast website doesn't show network calls being made. Extremely frustrated as there are no errors, and no indication as to why it's not responding. I followed the course step by step and it was working all along until this last moment. Please help! My code is identical to the courses code in the videos except for this one exception:
let weatherDictionary: NSDictionary = NSJSONSerialization.JSONObjectWithData(dataObject!, options: nil, error: nil) as NSDictionary
where dataObject has a ! operator in the parameters. It was necessary on my version of Xcode apparently because it showed an error without one
Please Help!!!
2 Answers
Misho Milicevic
5,597 PointsI have no idea what the answer is but I can tell you this... I've been attempting to discover the source of the problem so I tried putting some println statements back in the code. First I added a println(currentWeather.temperature) inside the completion handler block right below the creation of the currentWeather constant and it did nothing no output in the console. This was confusing so I added a second println just above the previous println and still below the currentWeather constant. I added println(response). I figured if any response exists I should have output. Eureka! it worked. All of a sudden I was getting console output and the labels on the app were updating. I then removed both println statements and the app still functions, the labels are updating.
Obviously there was some kind of glitch I'm guessing because there's no good reason I can think of why println statements would cause the code to compile properly after it seemed to be in some stalled state.
I don't know... If anyone can explain the enigma I'd love to hear it! Thanks!
Joshua Nye
2,547 PointsHappened to me too.
Save your project. Quit Xcode and the Simulator. Then reopen your Xcode project and run it again. Should work.
Misho Milicevic
5,597 PointsMisho Milicevic
5,597 PointsThanks Joshua, that was it! A glitch of some variety or another.