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 trial

iOS Build a Weather App with Swift (Retired) Data Modeling With Structures Cleaning Up Our Date

Chad Goodyear
Chad Goodyear
9,634 Points

Anyone got a Tardis?? I appear to be in Alcatraz and Thailand at the same time.

When I complete the lesson and it all appears to run fine, I notice that I'm getting the local time here in Thailand in the console.

I downloaded the source code and swapped my apiKey in to test it and it's the same.

Any thoughts?

mmm..am I exactly 12 hours different and being a muppet...possibly should have googled that first ;o)

2 Answers

Dominic Bryan
Dominic Bryan
14,452 Points

Have you got a snippet of your code where the apikey and coordinates are?

Without seeing it I can't tell but I'm guessing you went on Google maps while developing the app and taken your location co-ordinated, then you've travelled and just copied your old ones.

Can't be sure though so post some code for us

Chad Goodyear
Chad Goodyear
9,634 Points

Thanks for the reply.

I've tried a few variations since. My current code pointing to London is:

        var forecastLatAndLong: String = "51.507351,-0.127758"
        let baseURL = NSURL(string: "https://api.forecast.io/forecast/\(apiKey)/")
        let forecastURL = NSURL(string: forecastLatAndLong, relativeToURL: baseURL)

But looking at the downloadable code from teamTreehouse and reading the forecast API documentation i think the error is ...a 'feature'.

From the Forecast.io docs:

currently: A data point (see below) containing the current weather conditions at the requested location. <sic> Data point objects may contain the following properties: time: The UNIX time (that is, seconds since midnight GMT on 1 Jan 1970) at which this data point occurs.

That 'time' data point - despite being in 'currently' and bundled with the (in this case) remote information, is actually the 'local' time of the device requesting the weather. (it doesn't claim to be at the remote location from what i can see - just a logic trap)

So if your targeting your own GPS location then it doesn't matter - it works to let you know if a request is stale. But if you want to know the weather at home while you are on holiday - then it's misleading.

Or to put it another way; it tells you the weather not the time.

I don't think it's important at all now - as long as I didn't mess up my code.

I have a much better understanding of the example app I just built and the api for looking into it.

Thanks for your time.